Single-module Go SDK with integration sub-modules in github.com/getsentry/sentry-go.
AI commits MUST include:
Co-Authored-By: <agent model name> <agent-email-or-noreply@example.com>
make fmt2.make lint3.make vet4.make test-race
The root package sentry contains the entire public API.
Type-safe key-value builders used by structured logging and metrics:
attribute.String("key", "value")
attribute.Int("count", 42)
attribute.Float64("ratio", 0.5)
attribute.Bool("flag", true)Each lives in its own directory with a separate go.mod:
- HTTP middleware —
http/,gin/,echo/,fiber/,fasthttp/,iris/,negroni/ - Logging hooks —
logrus/,zerolog/,zap/,slog/ - Instrumentation —
httpclient/,otel/
When adding a new integration, mirror an existing one.
Current: transport.go (active) — HTTPTransport is the default implementation of an async transport. HTTPSyncTransport is the blocking variant for serverless.
Next: internal/telemetry/ + internal/http/ (not yet enabled) — Processor/buffer/scheduler architecture. Wired up in client.go (setupTelemetryProcessor) but commented out behind DisableTelemetryBuffer. Key parts:
internal/telemetry/processor.go— orchestrator; routes items to category-specific buffersinternal/telemetry/scheduler.go— weighted round-robin; errors get 5x priority over logsinternal/telemetry/ring_buffer.go— circular buffer with overflow policies and batch/timeout flushinginternal/telemetry/bucketed_buffer.go— groups items by trace IDinternal/http/transport.go—AsyncTransportwithHasCapacity()backpressureinternal/protocol/—Envelope,TelemetryIteminterfaces; log/metric batch types
The internalAsyncTransportAdapter in transport.go bridges old Transport to new TelemetryTransport.
- Follow existing conventions — check neighboring files first
- Maintain existing Go versions and dependencies unless explicitly asked to change them
gofmt -sformatting, doc comments on exports- Public API in root package; internals in
/internal - Thread safety required — guard shared state with mutexes
- Update tests when modifying behavior
Test tier preference (use the highest tier that covers what you need):
- Integration tests (default) — Prefer
internal/sentrytestwithsentrytest.Runorsentrytest.NewFixture, plus real routers /httptestrequests where needed. Prefer tests that use the public API. - Context-level tests — Prefer
sentrytest.NewContextorfixture.NewContext(parent)for tracing / context propagation tests. Prefersentrytest.NewFixturefor isolated client + hub setup when no HTTP server is needed. - Unit tests (sparingly) — Direct
NewClient+MockScopeonly for self-contained logic wheresentrytestwould add unnecessary indirection.
Conventions:
- Table-driven tests for multiple inputs through the same code path
t.Parallel()for tests that don't share global statecmp.Diffwithcmpopts.IgnoreFieldsfor*Eventcomparison — ignoreEventID,Timestamp,Sdk,sdkMetaData- Prefer
fixture.Flush()over directsentry.Flush(...)in tests built oninternal/sentrytest - Prefer
fixture.Events()as the captured event stream; inspectevent.Typein assertions instead of relying on separate fixture streams testifyfor assertions,internal/testutils/for non-assert test helpers like mocks and flush timing- All tests must pass
make test-race
What to test:
- Behavior users observe: Does middleware capture panics? Does
Flushdeliver events? Do trace headers propagate? - Edge cases at system boundaries: malformed DSN, nil
Hub, concurrent captures, context cancellation - Regressions: reproduce the failure before applying the fix
Thread safety:
- The SDK is used concurrently. Any test touching shared state (
Hub,Scope,CurrentHub) must either uset.Parallel()with isolated instances, or explicitly verify safety with goroutines andsync.WaitGroup.
/commit— Commit with Sentry conventional format/create-pr— Create PRs following Sentry conventions/code-review— Review PRs following Sentry practices/find-bugs— Audit local changes for bugs and security issues