OpenTelemetry
The Realm agent can export its logs, metrics and traces to an OpenTelemetry collector. Export is off by default. Only the agent is instrumented; the CLI is not.
Enable
Section titled “Enable”Point the standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable at your collector’s OTLP/HTTP endpoint before starting the agent:
OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318 realm agent startWhen the variable is set, the agent logs OpenTelemetry enabled with the endpoint at startup. If the exporters can’t be initialized, the agent exits with an error.
The agent exports over OTLP/HTTP (protobuf), usually on port 4318. OTLP/gRPC is not supported, so OTEL_EXPORTER_OTLP_PROTOCOL has no effect.
What is exported
Section titled “What is exported”| Signal | Content |
|---|---|
| Logs | Every agent log record at or above log_level. Logs are still written to stdout as well |
| Traces | One span per agent API request, named after the route (for example POST /loads/{loadName}/start) |
| Metrics | HTTP server metrics for the agent API, and Go runtime metrics (memory, GC, goroutines) |
Resource attributes
Section titled “Resource attributes”| Attribute | Value |
|---|---|
service.name |
agent |
service.instance.id |
The agent ID, stored in <data_path>/node.id |
realm.node.name |
The node name, added to logs and spans once a node configuration is loaded (not a resource attribute, as the name is only known after the node is configured) |
Add your own attributes, such as deployment.environment, with the standard OTEL_RESOURCE_ATTRIBUTES variable:
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=labTuning
Section titled “Tuning”The standard OpenTelemetry SDK environment variables apply. Realm changes two defaults to make data show up sooner:
| Variable | Realm default | SDK default | Description |
|---|---|---|---|
OTEL_BSP_SCHEDULE_DELAY |
1000 ms |
5000 ms |
Delay between trace batch exports |
OTEL_METRIC_EXPORT_INTERVAL |
3000 ms |
60000 ms |
Interval between metric exports |
Setting either variable overrides Realm’s default. Other variables, such as OTEL_EXPORTER_OTLP_HEADERS for collector authentication or the per-signal OTEL_EXPORTER_OTLP_<SIGNAL>_ENDPOINT variables, work as usual.
Troubleshooting
Section titled “Troubleshooting”Exporter errors, for example an unreachable collector, are logged as OpenTelemetry error warnings in the agent’s own log. Repeated identical errors are logged at most once a minute, with a suppressed count of the occurrences skipped in between.