---
title: "Making Go errors play nice with Sentry"
description: "Standard Go errors carry no stacktraces, which makes Sentry nearly useless, so incident.io standardized on pkg/errors and wraps every returned error to capture a trace at the deepest frame."
url: "https://swe.quest/articles/making-go-errors-play-nice-with-sentry-9b25169c23478cdf"
canonical: "https://incident.io/blog/golang-errors"
source: "incident.io"
published: "2022-04-06"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["go","observability","debugging"]
---

# Making Go errors play nice with Sentry

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2022-04-06, 8 min read, How-to. Original: [https://incident.io/blog/golang-errors](https://incident.io/blog/golang-errors)

## Summary

Standard Go errors carry no stacktraces, which makes Sentry nearly useless, so incident.io standardized on pkg/errors and wraps every returned error to capture a trace at the deepest frame. Repeated wrapping then produced one redundant stacktrace per wrap, cluttering Sentry and sometimes exceeding its size limit. The fix was an internal errors package, enforced by a lint rule, whose Wrap skips generating a new trace when the current stack is a prefix of the error's existing trace. Errors crossing goroutines or channels still keep their separate traces.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- Go error handling ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- stacktraces

## Keywords

Sentry, pkg/errors, xerrors, sentry-go

## Related posts

- [Observability as a superpower](https://swe.quest/articles/observability-as-a-superpower-5609b41c95a2309f.md): incident.io · 2024-11-04 · Medium · 8 min read · Observability, Go, Debugging, Incidents & postmortems
  Distributed tracing with OpenTelemetry lets incident.io engineers spot bugs before customers report them, by showing each request's route as a tree of timed spans that exposes slow steps, N+1 queries and duplicate calls.
- [Sentry JavaScript SDK v11 adds tracing for all JS platforms](https://swe.quest/articles/sentry-javascript-sdk-v11-adds-tracing-for-all-js-platforms-2ee0190e0544fb8c.md): Sentry · 2026-10-09 · Medium · 12 min read · Observability, JavaScript, Build systems, Runtimes & VMs
  Sentry's JavaScript SDK v11 replaces OpenTelemetry export-patching instrumentations (require-in-the-middle, import-in-the-middle, shimmer) with a source-code transformer that injects node:diagnostics\_channel tracingChannel calls into library functions, plus integrations that subscribe to those channels and emit Sentry spans.
- [Reducing our pager load](https://swe.quest/articles/reducing-our-pager-load-9bf7f4a021b251f9.md): incident.io · 2022-04-22 · Medium · 7 min read · Incidents & postmortems, Observability, Go, SRE
  incident.io pages on every Sentry error, and cut the resulting noise with four quick changes instead of switching to error-rate alerting.
- [Zero-config Debugging with Deno and OpenTelemetry](https://swe.quest/articles/zero-config-debugging-with-deno-and-opentelemetry-84e6e1786536c301.md): Deno · 2025-04-09 · Medium · 9 min read · Observability, Debugging, Runtimes & VMs, TypeScript
  Deno's built-in OpenTelemetry support (enabled with --unstable-otel) automatically correlates console.log output with trace IDs, creates spans for incoming and outgoing HTTP requests, propagates W3C tracecontext headers across services, and records request-count and latency metrics by status code, all without code changes.
- [Sentry's Flutter SDK 10.0: Streaming Traces and More Accurate Crash-Free Rates](https://swe.quest/articles/sentry-s-flutter-sdk-10-0-streaming-traces-and-more-accurate-crash-free-rates-a06a0e8843447c28.md): Sentry · 2026-10-14 · Medium · 3 min read · Mobile, Observability
  Sentry's Flutter SDK 10.0 switches tracing to a streaming model that sends finished spans in batches instead of waiting for the whole transaction, with \`Sentry.startSpan\` for custom instrumentation and an opt-out via \`SentryTraceLifecycle.static\`.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
