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 standardOTEL_EXPORTER_OTLP_*environment variables when you don't override them programmatically. - A
tracingbridge — if your app already uses thetracingcrate for structured logging (most Rust web services do),tracing-opentelemetryandopentelemetry-appender-tracingturn your existingtracing::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:
- Builds a
Resourcedescribing your service (service.name, and anything else you add). - Builds an OTLP/HTTP span exporter and log exporter with
SpanExporter::builder().with_http().build()/LogExporter::builder().with_http().build()— both readOTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_PROTOCOL, andOTEL_EXPORTER_OTLP_HEADERSautomatically. - Registers the resulting
SdkTracerProvider/SdkLoggerProviderglobally, and — if you usetracing— installstracing-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.tomldependencies, 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.