pub struct OpenTelemetry { /* private fields */ }Expand description
The OpenTelemetry plugin.
Every setting can come from configuration or the environment instead, so a
deployment tunes it without recompiling. A builder call always wins over
configuration, and configuration over the environment: a value written in
main.rs is a decision, a config key is a default, and an environment
variable is whatever the platform happened to inject.
| Config key | Environment | Meaning |
|---|---|---|
otel.enabled | OTEL_SDK_DISABLED | Export at all. On by default. |
otel.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | Collector base URL. |
otel.service | OTEL_SERVICE_NAME | service.name. Falls back to app.name. |
otel.headers | OTEL_EXPORTER_OTLP_HEADERS | k=v,k=v, percent-decoded. |
otel.protocol | OTEL_EXPORTER_OTLP_PROTOCOL | http/protobuf or http/json. |
otel.interval_ms | Flush interval (5000). | |
otel.batch | Spans per request (512). | |
otel.queue | Spans held before dropping (2048). | |
otel.retries | Retries per batch (3). | |
otel.logs.enabled | OTEL_LOGS_EXPORTER=otlp | Export logs too. Off by default. |
otel.logs.level | Lowest level exported (info). | |
otel.logs.queue | Log records held before dropping (2048). |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT points the log signal at a full URL of
its own; without it logs go to <endpoint>/v1/logs.
Implementations§
Source§impl OpenTelemetry
impl OpenTelemetry
pub fn new() -> Self
Sourcepub fn endpoint(self, endpoint: impl Into<String>) -> Self
pub fn endpoint(self, endpoint: impl Into<String>) -> Self
The collector’s base URL. /v1/traces and /v1/metrics are appended,
which is what the specification says a base endpoint means over HTTP.
pub fn service(self, name: impl Into<String>) -> Self
pub fn protocol(self, protocol: Protocol) -> Self
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
A header on every export — an API key for a hosted collector, usually.
Sourcepub fn attribute(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn attribute(self, key: impl Into<String>, value: impl Into<Value>) -> Self
A resource attribute: deployment.environment.name, service.version,
the pod name, anything that identifies this process rather than this
request.
pub fn flush_every(self, interval: Duration) -> Self
pub fn batch_size(self, spans: usize) -> Self
Sourcepub fn queue_limit(self, spans: usize) -> Self
pub fn queue_limit(self, spans: usize) -> Self
How many spans may wait before the newest are dropped.
pub fn retries(self, retries: u32) -> Self
Sourcepub fn logs(self, enabled: bool) -> Self
pub fn logs(self, enabled: bool) -> Self
Export logs as well as traces and metrics. Off unless asked for: logs can carry anything an application prints.
Sourcepub fn log_level(self, level: Level) -> Self
pub fn log_level(self, level: Level) -> Self
The lowest level exported as a log record. info by default.
pub fn enabled(self, enabled: bool) -> Self
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Export through a caller-supplied client. Tests fake it; production might use it to carry a proxy or a client certificate.