Rust

Send OpenTelemetry traces and logs from any Rust server to Sophonz using the official opentelemetry crates — no Sophonz package required.

You don't need a Sophonz package. Sophonz's collector speaks standard OTLP, so any Rust service can send it traces and logs by wiring up the official opentelemetry and opentelemetry-otlp crates and pointing them at Sophonz with environment variables.

What you get

  • The official Rust SDK — opentelemetry + opentelemetry_sdk + opentelemetry-otlp, which builds OTLP/HTTP exporters that read the standard OTEL_EXPORTER_OTLP_* environment variables when you don't override them programmatically.
  • A tracing bridge — if your app already uses the tracing crate for structured logging (most Rust web services do), tracing-opentelemetry and opentelemetry-appender-tracing turn your existing tracing::info!/#[instrument] calls into OTel spans and log records with no rewrite.
  • A small, explicit setup function you write once at startup — like Go, Rust has no bytecode-weaving agent, so this is a few lines of code rather than a flag.

How it works

Rust doesn't have a zero-code auto-instrumentation agent — there's no runtime bytecode to patch, and the compiler produces a static binary. Instead, you call a short setup function once at startup that:

  1. Builds a Resource describing your service (service.name, and anything else you add).
  2. Builds an OTLP/HTTP span exporter and log exporter with SpanExporter::builder().with_http().build() / LogExporter::builder().with_http().build() — both read OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, and OTEL_EXPORTER_OTLP_HEADERS automatically.
  3. Registers the resulting SdkTracerProvider / SdkLoggerProvider globally, and — if you use tracing — installs tracing-opentelemetry's layer so existing spans and log lines flow through the same pipeline.

From there, your framework's tracing middleware (tower-http, axum-tracing-opentelemetry, tracing-actix-web, tonic-tracing-opentelemetry) creates a server span for each request, and #[tracing::instrument] adds spans for your own functions.

CAUTION — Telemetry without a valid service.key is dropped silently

Sophonz's collector runs in enforce mode: it accepts the OTLP payload over the wire but silently drops anything that doesn't carry a resolvable service.key resource attribute. There's no error in your process and no rejected request — the console will simply stay empty. Double-check OTEL_RESOURCE_ATTRIBUTES (and OTEL_EXPORTER_OTLP_HEADERS) before assuming something else is broken.

Where to next

  • Installation — the Cargo.toml dependencies, the setup function, and the environment variables.
  • Configuration — what the collector requires, propagators, sampling, batching, and log levels.
  • Framework Middleware — a server span per request in axum, tower, actix-web, and tonic.
  • Distributed Tracing — continue browser and mobile traces and pass them on with reqwest.
  • Database Tracing — query spans with sqlx, diesel, and tokio-postgres.
  • Deployment — runtime notes, TLS, Kubernetes, and graceful shutdown.