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 API key (otel-logs-v0_9 in these examples).
Prerequisites
- A running Rootprint instance and its base URL — you’ll substitute it for
<your-rootprint>. - Go 1.21+ (for
log/slog). - An ingest API key scoped to your target index. In Settings → API keys, click Create ingest key, give it a name, and pick the index (
otel-logs-v0_9for the examples here). See API keys.
Setup
1
Initialise a module and install the OpenTelemetry packages
log/slog).2
Set environment variables
3
Minimal working example
4
Verify in Rootprint
Open Search, filter on
service_name:my-go-service, and your record should appear within ~2 seconds.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.
