Skip to content

Commit

Permalink
Always add tags for observability, other metrics may use them (#1312)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Jul 10, 2020
1 parent c30e815 commit 474407c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 56 deletions.
4 changes: 1 addition & 3 deletions obsreport/obsreport_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
55 changes: 11 additions & 44 deletions obsreport/obsreport_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
12 changes: 3 additions & 9 deletions obsreport/obsreport_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 474407c

Please sign in to comment.