Skip to content

Commit 77eafb2

Browse files
committed
address comment
1 parent bb300a5 commit 77eafb2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

internal/metricstagdecorators/metricstagdecorators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package metricstagdecorators
22

33
type DecoratorProperties struct{}
44

5-
// MetricsTagsDecorators is used to add custom tags to YARPC metrics.
5+
// MetricsTagsDecorators is used for adding custom tags to YARPC metrics.
66
type MetricsTagsDecorators interface {
77
ProvideTags(request DecoratorProperties) map[string]string
88
}

internal/observability/graph.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,17 @@ type streamEdge struct {
315315
func newEdge(logger *zap.Logger, meter *metrics.Scope, tagToIgnore *metricsTagIgnore, metricTagsDecorators []metricstagdecorators.MetricsTagsDecorators, req *transport.Request, direction string, rpcType transport.Type) *edge {
316316
tags := tagToIgnore.tags(req, direction, rpcType)
317317

318-
for _, decorator := range metricTagsDecorators {
319-
decoratorTags := decorator.ProvideTags(metricstagdecorators.DecoratorProperties{})
320-
for key, value := range decoratorTags {
321-
if _, exists := tags[key]; exists {
322-
logger.Warn("MetricsTagsDecorators is overwriting metric tag", zap.String("key", key), zap.String("old", tags[key]), zap.String("new", value))
318+
if len(metricTagsDecorators) > 0 {
319+
decoratorProperties := metricstagdecorators.DecoratorProperties{}
320+
321+
for _, decorator := range metricTagsDecorators {
322+
decoratorTags := decorator.ProvideTags(decoratorProperties)
323+
for key, value := range decoratorTags {
324+
if _, exists := tags[key]; exists {
325+
logger.Warn("MetricsTagsDecorators is overwriting metric tag", zap.String("key", key), zap.String("old", tags[key]), zap.String("new", value))
326+
}
327+
tags[key] = value
323328
}
324-
tags[key] = value
325329
}
326330
}
327331

0 commit comments

Comments
 (0)