Examples
Each example is one crate in the examples workspace. Run one with cargo run -p NAME from the examples folder. You can download the whole workspace as examples.zip from the site root. Every example prints a last line starting with ok:, so you can check at a glance that it ran to the end. The table lists what each one prints or stores.
| Example | Folder | Chapter | Command | What it does |
|---|---|---|---|---|
| first-signal | examples/first-signal | Setup and first signal | cargo run -p first-signal | Exports one span with attributes and an event to stdout. |
| traces | examples/traces | Traces | cargo run -p traces | Prints tracing spans to stdout, including two nested spans and an async task span. |
| metrics | examples/metrics | Metrics | cargo run -p metrics | Prints counter, histogram and up-down counter data points. |
| logs | examples/logs | Logs | cargo run -p logs | Prints log records emitted through the tracing bridge. |
| otlp-export | examples/otlp-export | Exporters | cargo run -p otlp-export | Sends one span to a local collector over OTLP, choosing gRPC or HTTP. |
| env-config | examples/env-config | Configuration | cargo run -p env-config | Builds a tracer provider from OpenTelemetry environment variables, prints the effective service name and sampler, and emits ten spans. |
| perf-bench | examples/perf-bench | Performance | cargo run -p perf-bench | Prints nanoseconds per iteration for several instrumentation cases. |
| sqlite-store | examples/sqlite-store | Spans in SQLite | cargo run -p sqlite-store | Stores finished spans in SQLite with a full-text index and queries them. |
| turso-store | examples/turso-store | Spans in Turso | cargo run -p turso-store | Stores finished spans in Turso through libsql. |
Run them all
The examples folder is one cargo workspace. All the example crates are its members. Run cargo check --workspace from the examples folder to check every example in one pass. This is the fastest way to confirm that all the code in the guide still compiles together.