From 474407c8377448577ba3cc29906aebe5373f7776 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 9 Jul 2020 17:13:10 -0700 Subject: [PATCH] Always add tags for observability, other metrics may use them (#1312) Signed-off-by: Bogdan Drutu --- obsreport/obsreport_exporter.go | 4 +-- obsreport/obsreport_processor.go | 55 +++++++------------------------- obsreport/obsreport_receiver.go | 12 ++----- 3 files changed, 15 insertions(+), 56 deletions(-) diff --git a/obsreport/obsreport_exporter.go b/obsreport/obsreport_exporter.go index c0efaee4827..0ba7e4d884d 100644 --- a/obsreport/obsreport_exporter.go +++ b/obsreport/obsreport_exporter.go @@ -195,9 +195,7 @@ func ExporterContext( ctx, _ = tag.New(ctx, tag.Upsert(LegacyTagKeyExporter, exporter, tag.WithTTL(tag.TTLNoPropagation))) } - if useNew { - ctx, _ = tag.New(ctx, tag.Upsert(tagKeyExporter, exporter, tag.WithTTL(tag.TTLNoPropagation))) - } + ctx, _ = tag.New(ctx, tag.Upsert(tagKeyExporter, exporter, tag.WithTTL(tag.TTLNoPropagation))) return ctx } diff --git a/obsreport/obsreport_processor.go b/obsreport/obsreport_processor.go index 682a5be4d74..1326861d78e 100644 --- a/obsreport/obsreport_processor.go +++ b/obsreport/obsreport_processor.go @@ -119,23 +119,14 @@ func ProcessorMetricViews(configType string, legacyViews []*view.View) []*view.V // the given context returning the newly created context. This context should // be used in related calls to the obsreport functions so metrics are properly // recorded. -func ProcessorContext( - ctx context.Context, - processor string, -) context.Context { - if useNew { - ctx, _ = tag.New( - ctx, tag.Upsert(tagKeyProcessor, processor, tag.WithTTL(tag.TTLNoPropagation))) - } +func ProcessorContext(ctx context.Context, processor string) context.Context { + ctx, _ = tag.New(ctx, tag.Upsert(tagKeyProcessor, processor, tag.WithTTL(tag.TTLNoPropagation))) return ctx } // ProcessorTraceDataAccepted reports that the trace data was accepted. -func ProcessorTraceDataAccepted( - processorCtx context.Context, - numSpans int, -) { +func ProcessorTraceDataAccepted(processorCtx context.Context, numSpans int) { if useNew { stats.Record( processorCtx, @@ -147,10 +138,7 @@ func ProcessorTraceDataAccepted( } // ProcessorTraceDataRefused reports that the trace data was refused. -func ProcessorTraceDataRefused( - processorCtx context.Context, - numSpans int, -) { +func ProcessorTraceDataRefused(processorCtx context.Context, numSpans int) { if useNew { stats.Record( processorCtx, @@ -162,10 +150,7 @@ func ProcessorTraceDataRefused( } // ProcessorTraceDataDropped reports that the trace data was dropped. -func ProcessorTraceDataDropped( - processorCtx context.Context, - numSpans int, -) { +func ProcessorTraceDataDropped(processorCtx context.Context, numSpans int) { if useNew { stats.Record( processorCtx, @@ -177,10 +162,7 @@ func ProcessorTraceDataDropped( } // ProcessorMetricsDataAccepted reports that the metrics were accepted. -func ProcessorMetricsDataAccepted( - processorCtx context.Context, - numPoints int, -) { +func ProcessorMetricsDataAccepted(processorCtx context.Context, numPoints int) { if useNew { stats.Record( processorCtx, @@ -192,10 +174,7 @@ func ProcessorMetricsDataAccepted( } // ProcessorMetricsDataRefused reports that the metrics were refused. -func ProcessorMetricsDataRefused( - processorCtx context.Context, - numPoints int, -) { +func ProcessorMetricsDataRefused(processorCtx context.Context, numPoints int) { if useNew { stats.Record( processorCtx, @@ -207,10 +186,7 @@ func ProcessorMetricsDataRefused( } // ProcessorMetricsDataDropped reports that the metrics were dropped. -func ProcessorMetricsDataDropped( - processorCtx context.Context, - numPoints int, -) { +func ProcessorMetricsDataDropped(processorCtx context.Context, numPoints int) { if useNew { stats.Record( processorCtx, @@ -222,10 +198,7 @@ func ProcessorMetricsDataDropped( } // ProcessorLogRecordsAccepted reports that the metrics were accepted. -func ProcessorLogRecordsAccepted( - processorCtx context.Context, - numRecords int, -) { +func ProcessorLogRecordsAccepted(processorCtx context.Context, numRecords int) { if useNew { stats.Record( processorCtx, @@ -237,10 +210,7 @@ func ProcessorLogRecordsAccepted( } // ProcessorLogRecordsRefused reports that the metrics were refused. -func ProcessorLogRecordsRefused( - processorCtx context.Context, - numRecords int, -) { +func ProcessorLogRecordsRefused(processorCtx context.Context, numRecords int) { if useNew { stats.Record( processorCtx, @@ -252,10 +222,7 @@ func ProcessorLogRecordsRefused( } // ProcessorLogRecordsDropped reports that the metrics were dropped. -func ProcessorLogRecordsDropped( - processorCtx context.Context, - numRecords int, -) { +func ProcessorLogRecordsDropped(processorCtx context.Context, numRecords int) { if useNew { stats.Record( processorCtx, diff --git a/obsreport/obsreport_receiver.go b/obsreport/obsreport_receiver.go index 43671aa5466..5d57000bd1c 100644 --- a/obsreport/obsreport_receiver.go +++ b/obsreport/obsreport_receiver.go @@ -247,15 +247,9 @@ func ReceiverContext( ctx, _ = tag.New(ctx, tag.Upsert(LegacyTagKeyReceiver, name, tag.WithTTL(tag.TTLNoPropagation))) } - if useNew { - mutators := make([]tag.Mutator, 0, 2) - mutators = append(mutators, tag.Upsert(tagKeyReceiver, receiver, tag.WithTTL(tag.TTLNoPropagation))) - if transport != "" { - mutators = append(mutators, tag.Upsert(tagKeyTransport, transport, tag.WithTTL(tag.TTLNoPropagation))) - } - - ctx, _ = tag.New(ctx, mutators...) - } + ctx, _ = tag.New(ctx, + tag.Upsert(tagKeyReceiver, receiver, tag.WithTTL(tag.TTLNoPropagation)), + tag.Upsert(tagKeyTransport, transport, tag.WithTTL(tag.TTLNoPropagation))) return ctx }