Skip to content

Commit c04d787

Browse files
authored
Merge pull request #176 from kenlabs/fix/counter_tag
add tag key in counter metrics, fix provider id lossing in record
2 parents badd20c + da4981b commit c04d787

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/metrics/metrics.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ var (
5757

5858
// Views
5959
var (
60-
bounds = []float64{0, 1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 1000, 2000, 5000}
61-
builtinViews = []*view.View{
60+
providerTagKey, _ = tag.NewKey("provider")
61+
bounds = []float64{0, 1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 1000, 2000, 5000}
62+
builtinViews = []*view.View{
6263
{Measure: PostProviderRegisterLatency, Aggregation: view.Distribution(bounds...)},
6364
{Measure: GetProviderHeadLatency, Aggregation: view.Distribution(bounds...)},
6465
{Measure: GetRegisteredProviderInfoLatency, Aggregation: view.Distribution(bounds...)},
@@ -68,8 +69,8 @@ var (
6869
{Measure: GetMetadataInclusionLatency, Aggregation: view.Distribution(bounds...)},
6970
{Measure: PostMetadataQueryLatency, Aggregation: view.Distribution(bounds...)},
7071
{Measure: GraphPersistenceLatency, Aggregation: view.Distribution(bounds...)},
71-
{Measure: ProviderNotificationCount, Aggregation: view.Count()},
72-
{Measure: ProviderPayloadCount, Aggregation: view.Count()},
72+
{Measure: ProviderNotificationCount, Aggregation: view.Count(), TagKeys: []tag.Key{providerTagKey}},
73+
{Measure: ProviderPayloadCount, Aggregation: view.Count(), TagKeys: []tag.Key{providerTagKey}},
7374
}
7475
)
7576

@@ -90,7 +91,7 @@ func Counter(ctx context.Context, m *stats.Int64Measure, t string, c int64) func
9091
return func() {
9192
_ = stats.RecordWithOptions(
9293
ctx,
93-
stats.WithTags(tag.Insert(metrics.Method, t)),
94+
stats.WithTags(tag.Insert(providerTagKey, t)),
9495
stats.WithMeasurements(m.M(c)),
9596
)
9697
}

0 commit comments

Comments
 (0)