Skip to main content
There is no Squasher crate for Rust. Send errors from Rust services with OpenTelemetry and the 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
The default features of opentelemetry-otlp send OTLP over HTTP. Squasher does not accept OTLP over gRPC.
2

Set the exporter variables

OTLP requests do not need the project ID. To get a key, see Create an ingest key.
3

Send tracing spans and events

src/main.rs
Without the 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, here checkout failed. The fields, such as error, 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.
A 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 uses reqwest 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")).
Then select Issues in the sidebar of your project. If the error does not appear, see Troubleshooting.

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.