Skip to main content
Rootprint accepts OpenTelemetry logs over OTLP HTTP. The Go SDK’s 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_9 for the examples here). See API keys.

Setup

1

Initialise a module and install the OpenTelemetry packages

Go 1.21+ is required (for log/slog).
2

Set environment variables

The %20 after Bearer is required. OTEL expects URL-encoded header values.
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 through slog: the bridge turns them into log-record attributes.
Or build a request-scoped logger with 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 %20 separator is not URL-encoded. Re-check OTEL_EXPORTER_OTLP_LOGS_HEADERS.
  • Nothing in Search: the batch processor buffers records. Short-lived programs must call provider.Shutdown(ctx) or provider.ForceFlush(ctx) before exit (the example above does so via defer).
  • otlploghttp.New returns context deadline exceeded: the process cannot reach the endpoint. Check DNS/TLS/firewall; try curl -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.