Skip to main content
There is no Squasher SDK for Java. Use the OpenTelemetry Java agent, which instruments Spring Boot and most Java frameworks without code changes, or post errors to the HTTP API. This page is tested with the Java agent 2.31 on Java 21.

Send errors with the Java agent

1

Download the agent

2

Set the exporter variables

The agent sends OTLP over HTTP by default, which Squasher needs. OTLP requests do not need the project ID. To get a key, see Create an ingest key.
3

Start your app with the agent

For Spring Boot, run the same command with your application jar.
The agent sends traces, logs, and metrics. It also sends the records of Logback, Log4j, and java.util.logging. Automatic AI triage runs only on issues from the production environment, so set deployment.environment.name to production in production.

How errors become issues

  • An unhandled exception in a request. The agent marks the server span as an error and records the exception on it. Squasher makes an issue from the span, titled with the span name, for example GET /checkout.
  • A log record at error level. For example, logger.error("checkout failed", e) in Logback, or Level.SEVERE in java.util.logging. Squasher makes an issue titled with the log message. The exception type, message, and stack trace become attributes of the record.
The issue page shows the stack trace from the exception.stacktrace attribute.

Send errors with the HTTP API

This class posts one error to the ingest endpoint with the JDK HTTP client. It needs Java 17 or later, and no other dependencies.
Squasher.java
Call Squasher.captureError(e) where you catch an exception. The request runs in the background, so a process that exits at once can lose it. stack is shown as the stack trace on the issue page. If your app already has a JSON library, use it to build the body. See the HTTP API for all fields.

Sentry SDK for Java

If your app already uses the Sentry SDK for Java, set its DSN to https://<ingest key>@ingest.squasher.ai/1. The ingest key selects the project; the SDK needs a number at the end. Squasher reads the gzip envelopes that the SDK sends and keeps its errors, traces, logs, metrics, and sessions. See Sentry for a move from Sentry.

Send a test error

  • Java agent: add a route that throws new IllegalStateException("Squasher test error"), and open it once.
  • HTTP API: call Squasher.captureError(new IllegalStateException("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 Java the same way:

Next steps

OpenTelemetry

See which OTLP data Squasher accepts.

HTTP API

See every field of the ingest endpoint.

Kubernetes

Send logs and metrics from a cluster.

Troubleshooting

Find out why an event does not appear.