mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 20:07:51 +00:00
Fix minor issues with metric labels and tests
This commit is contained in:
parent
c2c0a5c32f
commit
389acfc8ed
4 changed files with 24 additions and 9 deletions
|
|
@ -3217,7 +3217,11 @@ func (e *executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
if err := field.RowAttrStore().SetBulkAttrs(fieldMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
field.Stats.Count(MetricSetRowAttrs, 1, 1.0)
|
||||
}
|
||||
|
||||
if !opt.Remote {
|
||||
tags := []string{"index:" + index, "bulk:true"}
|
||||
e.Holder.Stats.CountWithCustomTags(MetricSetRowAttrs, int64(len(m)), 1.0, tags)
|
||||
}
|
||||
|
||||
// Do not forward call if this is already being forwarded.
|
||||
|
|
|
|||
|
|
@ -277,12 +277,16 @@ func (h *Handler) collectStats(next http.Handler) http.Handler {
|
|||
}
|
||||
|
||||
h.logger.Printf("%s %s %v %s", r.Method, r.URL.String(), dur, queryString)
|
||||
statsTags = append(statsTags, "speed:true")
|
||||
statsTags = append(statsTags, "slow:true")
|
||||
} else {
|
||||
statsTags = append(statsTags, "slow:false")
|
||||
}
|
||||
|
||||
pathParts := strings.Split(r.URL.Path, "/")
|
||||
if externalPrefixFlag[pathParts[1]] {
|
||||
statsTags = append(statsTags, "where:external")
|
||||
} else {
|
||||
statsTags = append(statsTags, "where:internal")
|
||||
}
|
||||
|
||||
statsTags = append(statsTags, "useragent:"+r.UserAgent())
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ func tagsToLabels(tags []string, logger logger.Logger) (labels prometheus.Labels
|
|||
tagParts := strings.SplitAfterN(tag, ":", 2)
|
||||
if len(tagParts) != 2 {
|
||||
// only process tags in "key:value" form
|
||||
logger.Debugf("Invalid Prometheus label: %v\n", tag)
|
||||
logger.Printf("Error: invalid Prometheus label: %v\n", tag)
|
||||
continue
|
||||
}
|
||||
labels[tagParts[0][0:len(tagParts[0])-1]] = tagParts[1]
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
||||
func TestStatsCount_SetRowAttrsBulk(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
|
|
@ -166,11 +166,15 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
|||
t.Fatal("field not found")
|
||||
}
|
||||
|
||||
field.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64, rate float64) {
|
||||
hldr.Holder.Stats = &MockStats{
|
||||
mockCountWithTags: func(name string, value int64, rate float64, tags []string) {
|
||||
if name != pilosa.MetricSetRowAttrs {
|
||||
t.Errorf("Expected %v, Results %s", pilosa.MetricSetRowAttrs, name)
|
||||
}
|
||||
|
||||
if tags[0] != "index:d" {
|
||||
t.Errorf("Expected db, Results %s", tags[0])
|
||||
}
|
||||
called = true
|
||||
},
|
||||
}
|
||||
|
|
@ -182,7 +186,7 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
||||
func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 1)
|
||||
defer c.Close()
|
||||
hldr := test.Holder{Holder: c[0].Server.Holder()}
|
||||
|
|
@ -196,12 +200,15 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
t.Fatal("idex not found")
|
||||
}
|
||||
|
||||
idx.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64, rate float64) {
|
||||
hldr.Holder.Stats = &MockStats{
|
||||
mockCountWithTags: func(name string, value int64, rate float64, tags []string) {
|
||||
if name != pilosa.MetricSetColumnAttrs {
|
||||
t.Errorf("Expected %v, Results %s", pilosa.MetricSetColumnAttrs, name)
|
||||
}
|
||||
|
||||
if tags[0] != "index:d" {
|
||||
t.Errorf("Expected db, Results %s", tags[0])
|
||||
}
|
||||
called = true
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue