otlploghttp exporter speaks this protocol directly, and the otelslog bridge lets Go’s standard slog API emit through it. Records land in the OTEL logs index pinned by your ingest token (default: otel-logs-v0_9).
Setup
Structured logging
Pass key/value pairs directly throughslog — the bridge turns them into log-record attributes.
slog.With so attributes propagate automatically:
Framework recipe: Gin
Set up the provider once, then write a middleware that enriches the request logger with route metadata.Troubleshooting
- 401 / 403 — the Bearer token is missing, malformed, or the
%20separator is not URL-encoded. Re-checkOTEL_EXPORTER_OTLP_LOGS_HEADERS. - Nothing in Search — the batch processor buffers records. Short-lived programs must call
provider.Shutdown(ctx)orprovider.ForceFlush(ctx)before exit (the example above does so viadefer). otlploghttp.Newreturnscontext deadline exceeded— the process cannot reach the endpoint. Check DNS/TLS/firewall; trycurl -X POST $OTEL_EXPORTER_OTLP_LOGS_ENDPOINT -H "Authorization: Bearer <token>"to isolate.- TLS errors against a self-signed endpoint — set
OTEL_EXPORTER_OTLP_CERTIFICATE=/path/to/ca.pem.
