Skip to main content
The opentelemetry-sdk for Zig is in alpha (v0.1.1, Zig 0.15.2). It is not yet proven in production. Expect breaking changes between releases.
Rootprint accepts OpenTelemetry logs over OTLP HTTP. The Zig SDK’s std.log bridge routes all standard library log calls to OpenTelemetry without changing a single call site. 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>.
  • Zig ≥ 0.15.2.
  • 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

Add the SDK to your project

Requires Zig ≥ 0.15.2. Run this in your project root:
Then add these lines to build.zig after your exe declaration:
The dependency key opentelemetry matches the SDK’s package name in its build.zig.zon; the import alias opentelemetry-sdk is what your code will @import.
2

Set environment variables

The %20 after Bearer is required. OTEL expects URL-encoded header values.
3

Minimal working example

Save as src/main.zig and run zig build run. The bridge reads the endpoint and auth header from the environment variables above.
4

Verify in Rootprint

Open Search, filter on service_name:my-zig-service, and your record should appear within ~2 seconds.

Structured logging

The std.log bridge maps Zig log levels to OpenTelemetry severity numbers automatically: Log messages and their format arguments become the log record body. Unlike Go’s slog.With, the std.log API does not support structured key/value attributes. Format args are interpolated into the message string.
For structured attributes, use the direct SDK API: see the examples/logs/ folder in the SDK repository.