log/slog, metrics flow through a meter provider, and traces through a tracer provider — all three sharing one resource identity and one OTLP/HTTP exporter configuration.
The application exports to an OpenTelemetry Collector, which forwards to Bronto. If you don’t run a Collector, export directly to Bronto instead — the code is identical, only two environment variables change.
Prerequisites
- Go 1.21 or later (required for
log/slog) - An OTel Collector reachable from your application, with
logs,metrics, andtracespipelines forwarding to Bronto — see Connect OpenTelemetry Collector to Bronto
Install dependencies
Configure the environment
The exporters read their endpoint from environment variables, so nothing in the code below is environment-specific./v1/logs, /v1/metrics, /v1/traces) to OTEL_EXPORTER_OTLP_ENDPOINT, and the URL scheme decides TLS — http:// for a plaintext local Collector, https:// for a secured one.
Two resource attributes determine how Bronto organises your data:
http://localhost:4318 is the standard OTLP/HTTP address for a Collector on the same host. Use the address reachable from your application if the Collector runs in another container, pod, or host. No authentication is needed between the application and the Collector — the Collector holds the Bronto API key.Initialise the SDK
otel.go
Instrument your application
Existingslog calls need no changes. Add spans and instruments for your own business logic:
main.go
Context-aware slog methods — InfoContext, WarnContext, ErrorContext — and pass the context returned by tracer.Start. That is what lets the bridge attach trace_id and span_id, so you can jump from a log line to its trace in Bronto.
Verify
Run your application, then check each signal in Bronto, filtering by theservice.name you set:
- Logs — the Search page, in the dataset named after your service
- Metrics — the Metric Explorer
- Traces — the Explore Traces page
- Confirm the Collector is running and reachable at
OTEL_EXPORTER_OTLP_ENDPOINT, and that its pipelines include anotlpreceiver and the Bronto exporters. - Confirm the endpoint includes a scheme. Without
http://, the exporters attempt TLS against a plaintext Collector. - The batch processors export on a background goroutine — keep the
defer shutdown(...)call so short-lived programs flush before exit.
Direct export to Bronto
Without a Collector, the application exports straight to Bronto over OTLP/HTTP. The code inotel.go is unchanged — point the endpoint at your Bronto region and add your API key:
See API Keys for how to create a key with ingestion permissions.
GenAI semantic conventions
If your application calls an LLM, OpenTelemetry’s GenAI semantic conventions definegen_ai.* span attributes for model, token usage, and prompt and response content.
Manual spans
There is no first-party GenAI auto-instrumentation package for Go, so set the attributes yourself around each model call:gen_ai.input.messages / gen_ai.output.messages) is opt-in by convention and off by default in the languages that have auto-instrumentation. Since you are setting attributes by hand, apply the same discipline — gate prompt and response content behind your own config flag rather than always sending it.
See the GenAI span conventions for the full attribute list.
For the recommended attribute set and Bronto search queries, see LLM Observability.
