Skip to main content

OpenTelemetry

Struct OpenTelemetry 

Source
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 keyEnvironmentMeaning
otel.enabledOTEL_SDK_DISABLEDExport at all. On by default.
otel.endpointOTEL_EXPORTER_OTLP_ENDPOINTCollector base URL.
otel.serviceOTEL_SERVICE_NAMEservice.name. Falls back to app.name.
otel.headersOTEL_EXPORTER_OTLP_HEADERSk=v,k=v, percent-decoded.
otel.protocolOTEL_EXPORTER_OTLP_PROTOCOLhttp/protobuf or http/json.
otel.interval_msFlush interval (5000).
otel.batchSpans per request (512).
otel.queueSpans held before dropping (2048).
otel.retriesRetries per batch (3).
otel.logs.enabledOTEL_LOGS_EXPORTER=otlpExport logs too. Off by default.
otel.logs.levelLowest level exported (info).
otel.logs.queueLog 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

Source

pub fn new() -> Self

Source

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.

Source

pub fn service(self, name: impl Into<String>) -> Self

Source

pub fn protocol(self, protocol: Protocol) -> Self

Source

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.

Source

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.

Source

pub fn flush_every(self, interval: Duration) -> Self

Source

pub fn batch_size(self, spans: usize) -> Self

Source

pub fn queue_limit(self, spans: usize) -> Self

How many spans may wait before the newest are dropped.

Source

pub fn retries(self, retries: u32) -> Self

Source

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.

Source

pub fn log_level(self, level: Level) -> Self

The lowest level exported as a log record. info by default.

Source

pub fn enabled(self, enabled: bool) -> Self

Source

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.

Source

pub fn install(self, router: &mut Router, config: &Config) -> Option<Exporter>

Install onto a router directly.

Returns the Exporter when it mounted. Applications go through Plugin; this is for tests and for an application that builds its own router.

Trait Implementations§

Source§

impl Default for OpenTelemetry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Plugin for OpenTelemetry

Source§

fn name(&self) -> &'static str

Shown by rustlavel route:list and in boot logs.
Source§

fn register(self: Box<Self>, setup: &mut Setup<'_>)

Add routes, middleware, and state.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.