From ef02c7841ee9ad19186f3719341d07c8c4764a50 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Thu, 27 Jun 2024 13:49:46 -0700 Subject: [PATCH] Return `SpanProcessor` ptr not `trace.SpanProcessor` from `baggagetrace.New` (#5810) Return the concrete type so user wanting underlying type do not need to make a type assertion. --- CHANGELOG.md | 1 + processors/baggage/baggagetrace/processor.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fac1ab9027..f4d25b1f6a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Improve performance of `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` with the usage of `WithAttributeSet()` instead of `WithAttribute()`. (#5664) - Update `go.opentelemetry.io/contrib/config` to latest released configuration schema which introduces breaking changes where `Attributes` is now a `map[string]interface{}`. (#5758) - Rename `BaggageKeyPredicate` to `Filter` in `go.opentelemetry.io/contrib/processors/baggage/baggagetrace`. (#5809) +- Return `*SpanProcessor` from `"go.opentelemetry.io/contrib/processors/baggage/baggagetrace".New` instead of the `trace.SpanProcessor` interface. (#5810) ## [1.27.0/0.52.0/0.21.0/0.7.0/0.2.0] - 2024-05-21 diff --git a/processors/baggage/baggagetrace/processor.go b/processors/baggage/baggagetrace/processor.go index cd8756c7c7b..2c1e965c833 100644 --- a/processors/baggage/baggagetrace/processor.go +++ b/processors/baggage/baggagetrace/processor.go @@ -18,19 +18,20 @@ type Filter func(key string) bool // AllowAllBaggageKeys allows all baggage members to be added to a span. var AllowAllBaggageKeys Filter = func(string) bool { return true } -// SpanProcessor is a processing pipeline for spans in the trace signal. +// SpanProcessor is a [trace.SpanProcessor] implementation that adds baggage +// members onto a span as attributes. type SpanProcessor struct { filter Filter } var _ trace.SpanProcessor = (*SpanProcessor)(nil) -// New returns a new SpanProcessor. +// New returns a new [SpanProcessor]. // // The Baggage span processor duplicates onto a span the attributes found // in Baggage in the parent context at the moment the span is started. // The passed filter determines which baggage members are added to the span. -func New(filter Filter) trace.SpanProcessor { +func New(filter Filter) *SpanProcessor { return &SpanProcessor{ filter: filter, }