log/slog — no log statement changes needed. Traces are added by configuring a tracer provider alongside the log provider.
Prerequisites
- Go 1.21 or later (required for
log/slog) - A running OTel Collector configured to forward logs to Bronto — see Connect Open Telemetry to Bronto
- OpenTelemetry Go SDK documentation
Install dependencies
| Package | Purpose |
|---|---|
sdk/log | LoggerProvider and processors |
exporters/otlp/otlplog/otlploghttp | OTLP/HTTP exporter |
contrib/bridges/otelslog | Bridges log/slog into OTel |
sdk/resource | Resource builder |
semconv/v1.26.0 | Standard attribute key constants |
Configure the log bridge
Theotelslog bridge replaces the default slog handler. All slog.Info(), slog.Warn(), and slog.Error() calls are forwarded to the OTel pipeline automatically.
otel_logging.go
Configure the OTLP exporter
Theotlploghttp.New call in the snippet above connects to the OTel Collector on localhost:4318 without TLS. If your Collector runs on a different host or port, update WithEndpoint accordingly.
To use TLS, remove WithInsecure() and ensure your Collector is configured with a valid certificate.
Set resource attributes
Resource attributes are attached to every log record exported from this process. Two attributes drive how Bronto organises incoming logs:| OTel attribute | Bronto concept | Description |
|---|---|---|
service.name | Dataset | Groups logs from one service |
service.namespace | Collection | Groups related services or a team’s services |
resource.WithAttributes in the setup above.
Complete example
main.go
defer shutdown(context.Background()) flushes any buffered log records before the process exits.
Verify log collection
After running your application, open the Search page in Bronto. Filter by the dataset name you set inservice.name — your log records should appear within a few seconds.
If no logs appear, check:
- The OTel Collector is running and reachable at the configured endpoint.
- The Collector’s pipeline includes a
logspipeline with anotlpreceiver and the Bronto exporter — see Connect Open Telemetry to Bronto. logging.Configureis called before the firstslogstatement.- The
shutdownfunction is called before process exit to flush buffered records.
Traces
Install tracing dependencies
Configure the tracer provider
otel_tracing.go
res from Configure so both signals share service.name and service.namespace.
Creating spans
slog.InfoContext (with the span context) to ensure the active span’s IDs are propagated to the log record.
Complete example
main.go
Direct export to Bronto
If you are not using an OTel Collector, export directly to Bronto by replacing the exporter configurations with the Bronto OTLP endpoints and your API key:| Region | Logs endpoint | Traces endpoint |
|---|---|---|
| EU | https://ingestion.eu.bronto.io/v1/logs | https://ingestion.eu.bronto.io/v1/traces |
| US | https://ingestion.us.bronto.io/v1/logs | https://ingestion.us.bronto.io/v1/traces |

