diff --git a/CHANGELOG.md b/CHANGELOG.md index 563225ed5..344251511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Fixed + +- Allow bumping OpenTelemetry Go (`go.opentelemetry.io/otel`) + without bumping the Splunk Distribution (`github.com/signalfx/splunk-otel-go`). + It fixes a merge resource runtime error, which could occur when + the application uses a version of OpenTelemetry Go that is newer + than the one which the Splunk Distribution is depending on. (#2759) + ## [1.12.0] - 2024-01-18 This release deprecates `jaeger-thrift-splunk` option support for `OTEL_TRACES_EXPORTER` diff --git a/distro/otel.go b/distro/otel.go index 94e9c78a3..98031ef73 100644 --- a/distro/otel.go +++ b/distro/otel.go @@ -26,7 +26,6 @@ import ( "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.24.0" ) var errShutdown = errors.New("SDK shutdown failure") @@ -115,22 +114,23 @@ func Run(opts ...Option) (SDK, error) { func newResource(ctx context.Context) (*resource.Resource, error) { // SDK's default resource. - defaultRes := resource.Default() - // Add additional detectors. - resWithDetectors, err := resource.New(ctx, - resource.WithDetectors( - // Add Splunk-specific attributes. - resource.StringDetector(semconv.SchemaURL, distroVerAttr, func() (string, error) { - return Version(), nil - }), - ), - // Add process and Go runtime information. + res := resource.Default() + + // Add process and Go runtime information. + procRes, err := resource.New(ctx, resource.WithProcess(), ) if err != nil { return nil, err } - res, err := resource.Merge(defaultRes, resWithDetectors) + res, err = resource.Merge(res, procRes) + if err != nil { + return nil, err + } + + // Add Splunk-specific attributes. + splunkRes := resource.NewSchemaless(attribute.String(distroVerAttr, Version())) + res, err = resource.Merge(res, splunkRes) if err != nil { return nil, err } @@ -194,6 +194,6 @@ func runMetrics(c *config, res *resource.Resource) (shutdownFunc, error) { } func serviceNameDefined(r *resource.Resource) bool { - val, ok := r.Set().Value(semconv.ServiceNameKey) + val, ok := r.Set().Value("service.name") return ok && val.Type() == attribute.STRING && !strings.HasPrefix(val.AsString(), "unknown_service:") }