Set up Go applications
Configure Go SDK exporters for application logs, traces and metrics. This setup requires SDK registration in your app. See the connection details first.
Install packages
go get go.opentelemetry.io/otel
go get go.opentelemetry.io/contrib/exporters/autoexport
go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
go get go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
go get go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
go get go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttpConfigure the process
Create and load the shared environment file, then build authentication and set the standard SDK header. autoexport reads the endpoint, protocol and exporter choices from the process environment. Use http/protobuf with the base HTTPS URL.
Register exporters and instrumentation
In your application's telemetry initialization:
- Create a span exporter with
autoexport.NewSpanExporter(ctx). Check the returned error and pass the exporter tosdktrace.NewTracerProviderwithsdktrace.WithBatcher. - Create a metric reader with
autoexport.NewMetricReader(ctx). Check the error and pass it tosdkmetric.NewMeterProviderwithsdkmetric.WithReader. - Create a log exporter with
autoexport.NewLogExporter(ctx). Check the error and connect it to your SDK logging provider and application logging integration. The onboarding setup marks Go logs as experimental. - Register the providers for your app and arrange for them to flush and shut down when the app stops.
- For
net/http, wrap your handler withotelhttp.NewHandler(mux, "/")to instrument requests.
Use the HTTP exporters installed above. Keep the endpoint in the environment so the exporters append the signal paths. If the app already initializes OpenTelemetry, update that setup instead of creating duplicate providers.
Start the app from the configured environment, generate logs and requests, then check the result.