open-telemetry / opentelemetry-go

OpenTelemetry Go API and SDK
https://opentelemetry.io/docs/languages/go
Apache License 2.0
5.17k stars 1.04k forks source link

Provide standard Tracer interface for all exporters #4700

Closed zetaab closed 10 months ago

zetaab commented 10 months ago

Problem Statement

With opentracing there was interface opentracing.Tracer (https://github.com/opentracing/opentracing-go/blob/master/tracer.go#L7) that all different exporters implemented somehow. This did it quite easy to implement application to support many different tracers. Example from traefik/traefik: it supports opentelemetry, zipkin, jaeger, instana, haystack, elastic and datadog. All through this interface.

However, now with opentelemetry there is no such interface. If I try to use trace.Tracer (https://github.com/open-telemetry/opentelemetry-go/blob/main/trace/trace.go#L504) Any of these exporters are not working with the interface implementation. So it is really difficult to make any interface implementations with opentelemetry. Or is there something that I am missing here?

Proposed Solution

Make it clear that there is interface x that every trace exporter should implement. Otherwise opentelemetry is just big mess to implement to applications.

pellared commented 10 months ago

Are you looking for https://pkg.go.dev/go.opentelemetry.io/otel/sdk/trace#SpanExporter?

Tracer != Exporter

I also suggest going through https://opentelemetry.io/docs/instrumentation/go/getting-started/.

Feel free to ask any further questions.

zetaab commented 10 months ago

yeah well tracerProvider.Tracer(serviceName) was basically what I was looking for