Skip to main content

Crate apollo_opentelemetry

Crate apollo_opentelemetry 

Source
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

Modules§

metrics
RAII guards for recording metrics that span asynchronous operations.

Macros§

default_instrumentation_scope
Returns an InstrumentationScope for 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§

OpenTelemetryConfig
Top-level OpenTelemetry configuration.
Telemetry
Unified telemetry management for traces, metrics, and logs.
TelemetryBuilder
Builder for configuring and creating a Telemetry instance.

Enums§

InitError
Errors that can occur during telemetry initialization.
RateLimitProcessorConfigError
Rate-limited processor configuration errors.

Traits§

ToValue
Converts a value into an OpenTelemetry Value for use as an attribute.

Attribute Macros§

traced
Instruments a function with an OpenTelemetry span.