Expand description
OpenTelemetry crate for Apollo platform.
This crate provides a standard way to configure and use OpenTelemetry.
§Getting Started
Create telemetry from configuration:
use apollo_configuration::parse_yaml;
use apollo_opentelemetry::{OpenTelemetryConfig, Telemetry};
let yaml = r#"
tracer_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: http://localhost:4318
"#;
let config: OpenTelemetryConfig = parse_yaml(yaml, &Default::default())?;
let telemetry = Telemetry::new(config)?;Or use the builder for more control:
use apollo_configuration::parse_yaml;
use apollo_opentelemetry::{OpenTelemetryConfig, Telemetry};
let yaml = r#"
tracer_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: http://localhost:4318
"#;
let config: OpenTelemetryConfig = parse_yaml(yaml, &Default::default())?;
let telemetry = Telemetry::builder(config)
.with_global_tracer_provider()
.with_global_meter_provider()
.build()?;§Feature Flags
otlp- Enable OTLP exporters (HTTP and gRPC)honeycomb- Enable Honeycomb exporternew-relic- Enable New Relic exportergrafana-cloud- Enable Grafana Cloud exporterdatadog-otlp- Enable Datadog OTLP intake exporter
Modules§
- metrics
- RAII guards for recording metrics that span asynchronous operations.
Macros§
- default_
instrumentation_ scope - Returns an
InstrumentationScopefor the calling crate. - span
- Creates a new span using OpenTelemetry.
- span_
attr - Sets attributes on the current span.
- span_
err - Sets the current span status to error with a formatted message.
- span_
event - Adds an event to the current span.
- span_ok
- Sets the current span status to ok.
Structs§
- Open
Telemetry Config - Top-level OpenTelemetry configuration.
- Telemetry
- Unified telemetry management for traces, metrics, and logs.
- Telemetry
Builder - Builder for configuring and creating a
Telemetryinstance.
Enums§
- Init
Error - Errors that can occur during telemetry initialization.
- Rate
Limit Processor Config Error - Rate-limited processor configuration errors.
Traits§
Attribute Macros§
- traced
- Instruments a function with an OpenTelemetry span.