Exporters
In order to visualize and analyze your telemetry, you will need to export your data to an OpenTelemetry Collector or a backend such as Jaeger, Zipkin, Prometheus or a vendor-specific one.
As part of OpenTelemetry Go you will find many exporters being available. Among them, the OpenTelemetry Protocol (OTLP) exporters provide the best experience for you as an end-user, since it is a general-purpose telemetry data delivery protocol designed in the scope of the OpenTelemetry project.
To learn more about the OTLP protocol, you can read the OTLP Specification.
Below you will find some introductions on how to set up exporters for OTLP and other common protocols in your code.
OTLP endpoint
To send trace data to an OTLP endpoint (like the collector or Jaeger >= v1.35.0) you’ll want to configure an OTLP exporter that sends to your endpoint.
Using HTTP
import (
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
)
func installExportPipeline(ctx context.Context) (func(context.Context) error, error) {
client := otlptracehttp.NewClient()
exporter, err := otlptrace.New(ctx, client)
if err != nil {
return nil, fmt.Errorf("creating OTLP trace exporter: %w", err)
}
/* … */
}
To learn more on how to use the OTLP HTTP exporter, try out the otel-collector
Jaeger
To try out the OTLP exporter, since v1.35.0 you can run Jaeger as an OTLP endpoint and for trace visualization in a docker container:
docker run -d --name jaeger \
-e COLLECTOR_OTLP_ENABLED=true \
-p 16686:16686 \
-p 4318:4318 \
jaegertracing/all-in-one:latest
Prometheus
Prometheus export is available in the
go.opentelemetry.io/otel/exporters/prometheus
package.
Please find more documentation on GitHub