pub struct ObservabilityConfig {
pub enabled: bool,
pub service_name: Option<String>,
pub service_version: Option<String>,
pub environment: Option<String>,
pub resource_attributes: BTreeMap<String, String>,
pub logs: LogsConfig,
pub traces: TracesConfig,
pub metrics: MetricsConfig,
pub otlp: OtlpConfig,
}Expand description
Logs, traces and metrics — what the server says about itself, and where it says it.
Everything here is off-by-default except the logs, which every process has
always written to the terminal. Turning enabled on does not by itself send
anything anywhere: it arms the section, and an [observability.otlp]
endpoint is what makes traces and metrics leave the process. Without one
the spans are still built and still carried through the logs — so a
deployment gets request ids and structured errors for free, and an OTLP
collector only when it has somewhere to put the data.
§Why OTLP and nothing else
OTLP is the wire format every backend now speaks — Jaeger, Tempo, Honeycomb,
Datadog, New Relic, the OpenTelemetry Collector — so one exporter reaches
all of them, and a deployment that wants something exotic points this at a
Collector and translates there rather than here. The transport is HTTP
(:4318), not gRPC: it goes through the reqwest client this binary
already links, where gRPC would compile a second RPC stack for the same
bytes.
§Environment
The standard OTEL_* variables are read when the corresponding key is
unset — OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS,
OTEL_SERVICE_NAME, OTEL_TRACES_SAMPLER_ARG — because that is how a
sidecar-injected collector configures the pods around it, and an app should
not have to be rebuilt to be scraped.
Fields§
§enabled: boolArm the section. Off means: log to the terminal as always, build no spans, export nothing.
service_name: Option<String>What this service calls itself in a trace. Unset falls back to
OTEL_SERVICE_NAME, then to the app’s name, then to apiplant.
service_version: Option<String>The build being traced. Unset falls back to the apiplant version,
which is right until an app starts shipping a version of its own.
environment: Option<String>production, staging, … Exported as deployment.environment.name,
which is the attribute every backend groups by first.
resource_attributes: BTreeMap<String, String>Extra resource attributes attached to every span and metric —
region, tenant, k8s.pod.name. Values may reference the
environment like any other string here.
logs: LogsConfig§traces: TracesConfig§metrics: MetricsConfig§otlp: OtlpConfigImplementations§
Source§impl ObservabilityConfig
impl ObservabilityConfig
Sourcepub fn endpoint(&self) -> Option<String>
pub fn endpoint(&self) -> Option<String>
The endpoint to export to, config first and then the environment.
None means nothing is exported — which is a supported way to run:
spans still carry the logs, they simply stay in the process.
Sourcepub fn service_name(&self, app_name: &str) -> String
pub fn service_name(&self, app_name: &str) -> String
The name this service reports itself under.
Sourcepub fn export_headers(&self) -> BTreeMap<String, String>
pub fn export_headers(&self) -> BTreeMap<String, String>
Every header sent with an export, the config’s merged over anything
OTEL_EXPORTER_OTLP_HEADERS supplied — the file is the more specific
statement, so it wins a collision.
Trait Implementations§
Source§impl Clone for ObservabilityConfig
impl Clone for ObservabilityConfig
Source§fn clone(&self) -> ObservabilityConfig
fn clone(&self) -> ObservabilityConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more