Skip to main content
Use the Go handler when your application already logs through log/slog and you want the same records to flow into Squasher.

Installation

Configuration

Create one handler with your Squasher credentials, then build a slog.Logger from it.
main.go

Usage Example

main.go
The handler sends records asynchronously, so a final Flush() call is useful during shutdown paths, CLI commands, and tests.

Custom Attributes

Use WithAttrs() for shared fields and WithGroup() for nested attributes that should stay together.
main.go
Those attributes are preserved in the structured payload that Squasher receives, which makes them available for filtering and debugging. Use standard attribute names such as event.name, service.version, trace_id, and span_id. The handler keeps numbers and booleans typed and uses trace identifiers for log correlation.

Outcome sampling

Start with the default policy, then change only the rate you need:
Errors and slow records stay at full fidelity by default. Records with the same trace_id get the same sampling decision.

Agent handoff