tracing crate, or post them to the HTTP API. This page is tested with the OpenTelemetry crates
0.33 on Rust 1.97.
Send errors with OpenTelemetry
1
Add the crates
Cargo.toml
opentelemetry-otlp send OTLP over HTTP. Squasher does not accept
OTLP over gRPC.2
Set the exporter variables
3
Send tracing spans and events
src/main.rs
Targets filter, the log bridge also exports the logs of the exporter itself.How errors become issues
- A
tracing::error!event becomes a log record at error level. Squasher makes an issue titled with its message, herecheckout failed. The fields, such aserror, become attributes. - The same event inside an instrumented function also marks its span as an error. Squasher makes a
second issue from the span, titled with the span name, here
checkout.
tracing event does not carry a stack trace, so these issues have none. For stack traces on the
issue page, use the HTTP API.
Send errors with the HTTP API
Post each error to the ingest endpoint. This example usesreqwest with the blocking and json
features, and serde_json.
src/squasher.rs
message is the only required field. stack is shown as the stack trace on the issue page. In an
async service, use the async reqwest::Client instead. See the HTTP API
for all fields and for batches.
Send a test error
- OpenTelemetry: run
tracing::error!("Squasher test error"), then shut down the providers. - HTTP API: run
capture_error(&std::io::Error::other("Squasher test error")).
Give the setup to a coding agent
Copy this prompt into your coding agent to set up Rust the same way:Next steps
OpenTelemetry
See which OTLP data Squasher accepts.
HTTP API
See every field of the ingest endpoint.
Collector tail sampling
Keep error traces and sample the rest.
Troubleshooting
Find out why an event does not appear.