Skip to main content

Crate uptrace

Crate uptrace 

Source
Expand description

OpenTelemetry Rust distribution for Uptrace.

This crate configures the OpenTelemetry Rust SDK to export traces, metrics, and logs to Uptrace with sensible defaults: OTLP exporters with gzip compression, delta metrics temporality, time-ordered trace IDs, host/OS/process resource detection, and the W3C TraceContext + Baggage propagator.

§Quickstart

use opentelemetry::global;
use opentelemetry::trace::{TraceContextExt, Tracer};

fn main() -> Result<(), uptrace::Error> {
    let uptrace = uptrace::Uptrace::builder()
        // Defaults to the UPTRACE_DSN env var.
        .with_dsn("https://<token>@api.uptrace.dev?grpc=4317")
        .with_service_name("myservice")
        .with_service_version("1.0.0")
        .with_deployment_environment("production")
        .build()?;

    let tracer = global::tracer("app_or_crate_name");
    tracer.in_span("main", |cx| {
        println!("trace: {}", uptrace.trace_url(cx.span().span_context()));
    });

    uptrace.shutdown()
}

§Cargo features

§Environment variables

  • UPTRACE_DSN: the DSN used when UptraceBuilder::with_dsn is not called.
  • UPTRACE_DISABLED: when set, UptraceBuilder::build returns a no-op Uptrace.
  • Standard OTEL_* variables such as OTEL_RESOURCE_ATTRIBUTES, OTEL_SERVICE_NAME, OTEL_TRACES_SAMPLER, and OTEL_BSP_*.

Re-exports§

pub use opentelemetry;
pub use opentelemetry_sdk;

Structs§

Dsn
Uptrace data source name, for example, https://<token>@api.uptrace.dev?grpc=4317.
LogsConfig
Configuration for exporting logs to Uptrace.
MetricsConfig
Configuration for exporting metrics to Uptrace.
TracesConfig
Configuration for exporting traces to Uptrace.
Uptrace
Configured OpenTelemetry providers that export data to Uptrace.
UptraceBuilder
Builder for Uptrace. Created with Uptrace::builder.
UptraceIdGenerator
ID generator that prefixes trace IDs with the current time.

Enums§

Error
Errors returned by this crate.
Protocol
OTLP transport used to send data to Uptrace.