Skip to main content
Send Go errors to Squasher in one of two ways: log them with the squasher-go handler for log/slog, or record them on spans with OpenTelemetry. This page is tested with squasher-go v0.1.0 and OpenTelemetry Go 1.46 on Go 1.27.

Send logs with the slog handler

1

Install the module

The module needs Go 1.21 or later. To get your ingest key and project ID, see Create an ingest key.
2

Create the handler

main.go
The handler sends each record as one event. Records at slog.LevelError become issues, titled with the log message. The attributes go to the event as tags and extra data, and an error value becomes its message text. A service attribute sets the service name in Squasher. Flush waits until the queued records are sent. Close sends the rest and stops the handler. Call one of them before the process exits, or the last records are lost.

Handler options

When the ingest key or the project ID is empty, the handler sends nothing.

Handler limits

  • The handler sends no environment. Automatic AI triage runs only on production issues, so it does not run on these issues. To triage one, select Run triage in the Squasher triage card on the issue page. For an environment, use OpenTelemetry.
  • The handler sends no stack traces.
  • It sends one HTTP request for each record, without batches or retries. When the queue is full, or when a request fails, the record is lost.

Send errors with OpenTelemetry

1

Install the modules

2

Set the exporter variables

This guide uses the HTTP exporter. OTLP requests do not need the project ID. If your Go deployment uses the gRPC exporter, send it to the Collector URL on port 443 as described in Send over gRPC.
3

Start a tracer provider

main.go
provider.Shutdown sends the spans that are still queued.
4

Record errors on spans

checkout.go
A span with the error status becomes an issue, titled with the status description, for example card declined. RecordError on a span without the error status also makes an issue, titled with the error message.

Send a test error

  • slog handler: run slog.Error("Squasher test error"), then call handler.Flush.
  • OpenTelemetry: end a span with span.SetStatus(codes.Error, "Squasher test error"), then call provider.Shutdown.
Then select Issues in the sidebar of your project. If the error does not appear, see Troubleshooting. To post errors without a module, use the HTTP API.

Give the setup to a coding agent

Copy this prompt into your coding agent to set up Go the same way:

Next steps

OpenTelemetry

See which OTLP data Squasher accepts.

HTTP API

Post events without a module.

Read AI triage

Learn what the triage summary tells you.

Troubleshooting

Find out why an event does not appear.