Go error tracking

Know when your Go app breaks, before your users do

ForgeOps connects the errors your Go app reports to the deploys, traces, and changes around them, so when production breaks, the incident already says who's affected, what changed, and where to look.

Middleware reports a panic that escapes a request handler, then lets it recover exactly as it would without this client. Running on ForgeOps' own dedicated infrastructure, so nothing about a Go app's errors or its users' data gets routed through a third-party error-tracking vendor. See an incident investigated →

Install

go get github.com/Luke-Popwell/forge-ops-tracker-go

import forgeops "github.com/Luke-Popwell/forge-ops-tracker-go"

forgeops.Init(func(c *forgeops.Configuration) {
    c.DSN = "https://<api_key>@getforgeops.net/api/v1/events"
})

Middleware reports a panic that escapes a request handler, then lets it recover exactly as it would without this client.

Every client reports the same shape

Wherever it comes from, an event arrives with an exception class, a message, and a backtrace, plus whatever environment/release/server context that client can gather on its own. ForgeOps fingerprints and groups on the first three, so a Go app's issues list works exactly the same way every other language's does: report the same bug a thousand times and it's still one row, not a thousand.

No agent, no sidecar: it's a plain HTTPS POST to ForgeOps' own ingestion API, so nothing about a Go app's traffic gets routed through a third-party pipeline first.


Works with your framework


The Go client hooks in at the framework level, not by wrapping individual calls, so nothing about how you already write Go code has to change.


net/http (chi, gorilla/mux)

forgeopshttp.Middleware wraps any handler with the same signature, reporting a panic before the server recovers it.

Gin

forgeopsgin.Recovery() is a drop-in replacement for gin.Recovery(), not an addition alongside it.

Plain functions

CaptureError reports an error you already have; Recover reports a panic from a deferred call, right where you'd otherwise just log it, and waits for the report to go out before re-panicking.

Scripts, CLIs and cron jobs

Go has no exit hook, so defer forgeops.Flush(2 * time.Second) right after Init: anything still queued when main returns is sent first.

What it looks like

The issue list

Every Go issue reported into a project shows up here: title, status, assignee, event count, and when it was last seen, the same columns as any other language's project.

The issue list for a project reporting from a Go app

The issue detail

Every occurrence keeps its own timestamp, environment, release, and server, plus the backtrace exactly as Go reported it, expandable per occurrence rather than flattened into one generic stack.

A Go issue's page in ForgeOps: its title, the exception class and the code it came from beneath it, then its verdict with its failure count, customers affected, and when it was first seen, above the triage buttons

Alerting

A new Go issue, a regression, or a spike past a threshold you set can reach Slack, Microsoft Teams, email, PagerDuty, Opsgenie, or a generic webhook, configured per project, per trigger.

Notification rules configured per trigger and channel, e.g. a new issue to Slack, a regression to email

Heartbeats

For the failure mode error tracking can't see on its own: a Go cron job or recurring task that's supposed to run but silently stopped. Each heartbeat gets its own ping URL and its own grace period before it alerts.

A heartbeat's ping URL and status, showing its expected interval, grace period, and last check-in

Performance monitoring

forgeopshttp.Timing (or forgeopsgin.Timing() under Gin) times every request too, bucketed by transaction and flushed as a small periodic aggregate on a time.Ticker, never one network call per request, the same delivery philosophy as everything else in this client. Under Gin the transaction is the matched route pattern (e.g. "GET /users/:id", gin.Context.FullPath(), not the raw path, so a distinct user id doesn't explode into its own separate transaction); plain net/http has no route-matching concept of its own to read a pattern from, so that integration reports the literal request path instead. Requires a plan that includes performance monitoring; on a plan that doesn't, the periodic reports are accepted but not recorded (the response says why), so a working setup never looks broken. Each report also carries a small latency histogram, so ForgeOps shows an approximate p50/p95/p99 per transaction, not just an average, accurate to the width of the latency bucket a duration falls into.

The Performance page, showing each transaction's request count and p50, p95 and p99 latency, plus slow queries
http.ListenAndServe(":8080", forgeopshttp.Middleware(forgeopshttp.Timing(mux)))
// or, under Gin: router.Use(forgeopsgin.Timing())

forgeops.Init(func(c *forgeops.Configuration) {
    c.TrackPerformance = false                    // opt out entirely
    c.PerformanceFlushInterval = 30 * time.Second // default 60 seconds
})

Distributed tracing

The Timing middlewares (net/http and Gin) open a trace on each request's own context and finish it for you. Inside a handler, open a span from that context and pass the returned context to everything it covers, so anything opened from it nests underneath. Only a slow request's trace is ever sent: whether it crossed the threshold (one second by default, configurable) is decided entirely inside your process, so a fast request costs nothing over the wire. Requires a plan that includes distributed tracing.

A trace's waterfall for one slow request, with its controller, service, database, cache and HTTP spans
ctx, end := forgeops.StartSpan(r.Context(), "charge card", "service", map[string]any{"order_id": id})
defer end()
// pass ctx to everything the span covers: anything opened from it nests under "charge card"

Outbound HTTP calls become spans too, through a transport that wraps your own.

client := &http.Client{Transport: forgeops.Transport(nil)}
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
resp, err := client.Do(req)

Errors now carry the request they happened in: its endpoint (POST /checkout) and its trace id. An issue names its affected endpoint, each occurrence links to its exact trace, and a request that fails is always traced, however fast. The trace follows the request across services in the standard traceparent header, picked up from whatever called your net/http or Gin app through the middleware and passed on to whatever it calls through forgeops.Transport with the request's context, so once the projects are linked in ForgeOps an error shows the errors another project raised in the same request. Needs tag v0.5.0.

One trace waterfall running from a mobile app's checkout tap into the API it called, with the API's controller, database, and payment calls nested underneath, each project labeled
client := &http.Client{Transport: forgeops.Transport(nil)}

func checkout(w http.ResponseWriter, r *http.Request) {
    req, _ := http.NewRequestWithContext(r.Context(), http.MethodPost, "https://payments.internal/charge", nil)
    resp, err := client.Do(req) // sends traceparent: 00-<this request's trace id>-<this call's span id>-01
    // ...
}

forgeops.Init(func(c *forgeops.Configuration) {
    c.TracePropagationTargets = []any{"payments.internal"} // only these hosts; nil (the default) means all
})

SQL in a request

When the request an issue failed in was traced, the issue opens with its slowest query: how long it took, its share of the request's time, how many queries the request ran, and a likely N+1 warning when the same statement ran five or more times. This client doesn't wrap database/sql or any driver, so start a database span with StartDatabaseSpan and pass its SQL; the query's arguments are never taken. The statement is masked before it leaves your process, every string and number replaced with a question mark, and the same SQL shows under that span's bar in the trace's waterfall. Needs tag v0.7.0, on a plan that includes distributed tracing.

An issue's Slowest query in this request card: a 2.7 second order search that took 86% of a 3.2 second request, a likely N+1 warning for a line_items query run 24 times, and the query plan calling out a sequential scan on orders
const openOrders = "SELECT id, total FROM orders WHERE customer_id = $1 AND status = 'open'"

func orders(w http.ResponseWriter, r *http.Request) {
    ctx, end := forgeops.StartDatabaseSpan(r.Context(), "load open orders", openOrders, "postgresql")
    rows, err := db.QueryContext(ctx, openOrders, r.URL.Query().Get("customer"))
    end()
    if err != nil {
        http.Error(w, "unavailable", http.StatusServiceUnavailable)
        return
    }
    defer rows.Close()
    // Sent as "SELECT id, total FROM orders WHERE customer_id = $1 AND status = ?"
}

What changed

A feature flag flip or a config edit can break things with no deploy at all. Record one with RecordChange and it shows under What changed on any issue that starts in the next two hours, and on the project's Changes page beside your deploys, labeled potentially relevant, never as the cause. Changes between deploys are detected for you: the first Init sends the Go version and every module version compiled into the binary, read from its own build info, so a dependency upgrade shows up with nothing to call. Environment variable names (never values) are opt-in. Needs tag v0.6.0, on a plan that includes change tracking.

An issue's verdict listing what changed just before it started, labeled potentially relevant: the gateway_retry_v2 flag turned on for 100% of checkouts 3 minutes before, and a stripe upgrade and a new environment variable detected at startup after the deploy 7 minutes before
forgeops.Init(func(c *forgeops.Configuration) {
    c.DetectChanges = true    // the default; false sends no startup snapshot
    c.TrackEnvVarNames = true // default false; names only, never values
})

forgeops.RecordChange(forgeops.ChangeKindFeatureFlag, "gateway_retry_v2 turned on for 100% of checkouts", &forgeops.ChangeOptions{
    Details: map[string]any{"flag": "gateway_retry_v2", "from": "10%", "to": "100%"},
    Actor:   "priya@example.com",
})

Custom metrics and infrastructure monitoring

Track a business event you name yourself (a signup, a payment) or a reading from one of your own hosts, with one explicit call each; nothing is automatic. Pass the value explicitly: 1 for a bare counter, or a real amount (it can be negative, for a refund). A captured value is stored as its own row, so counts and sums you compute later are exact. Calls are buffered and flushed as one batch in the background, so they are safe to make inside a request, and FlushMetrics sends whatever is buffered right now (in a short-lived program, defer forgeops.Flush(2 * time.Second), which sends metrics and errors alike). An empty hostname defaults to the configured server name. Requires a plan that includes custom metrics and infrastructure monitoring.

A dashboard with custom-metric widgets (orders placed, checkout conversion, orders over time) and infrastructure widgets (average readings by host and by metric)
forgeops.CaptureMetric("signup", 1)    // a bare counter
forgeops.CaptureMetric("payment", 49)  // a real magnitude; it may be negative (a refund)

forgeops.CaptureInfrastructureMetric("cpu", 0.42, "")      // "" defaults to Configuration.ServerName
forgeops.CaptureInfrastructureMetric("disk", 0.81, "db-1")
forgeops.FlushMetrics()                                    // send right now

Database errors

When an error comes from a database call, the issue shows which stored procedure, table or view its SQL touched, so you know where to start looking. A Go error carries no SQL of its own, so wrap the error with WithSQL where you ran the query. CaptureError, Recover and the middleware then find it with no extra call, and errors.Is and errors.As still work through it. The names are sent by default and are identifiers, never values. The SQL statement itself is opt-in, with every string and number replaced by a question mark before it leaves your app, and a project setting can stop ForgeOps storing the statement at all.

An issue occurrence's Database section, naming the stored function and the view the failing query touched, with the statement's values replaced by question marks
rows, err := db.QueryContext(ctx, query, args...)
if err != nil {
    return forgeops.WithSQL(err, query)
}

// Opt in to also sending the masked statement (default false).
forgeops.Init(func(c *forgeops.Configuration) {
    c.CaptureSQLStatement = true
})

Questions

Do I need to change how I already handle errors?

Almost never. Every client hooks the framework's own exception handling directly, the same way the install snippet above shows, so your own logs, error pages, and rescue blocks keep working exactly as they did before, and ForgeOps just also finds out about it. The one common exception is a background-job runner that doesn't forward through that same mechanism on its own; that needs one small hook added instead, not a change to anything already there.

Where does the data actually go?

Straight to ForgeOps' own ingestion API over plain HTTPS. No agent, no sidecar, and no third-party ingestion service in between, so nothing about your app's traffic or its users' data gets routed through anyone else's pipeline first.

What happens if the same bug fires a thousand times?

It's fingerprinted from its exception class, message, and backtrace, so a thousand reports of the same bug still show up as one issue with an event count of 1,000, not a thousand separate rows to dig through. And a runaway loop can't use up your monthly event quota: once one issue repeats faster than your plan's hourly limit (50 an hour on Free), further repeats are still counted, and still count toward spike alerts, but they aren't stored or charged to your quota.

Is anything scrubbed before it's stored?

Yes. Emails, credit card numbers, and known API key/token formats are redacted out of every event before it's even written, on every plan, with room for per-project custom field names on top of the defaults.

Try it with your own Go app

Free plan included, no credit card required. New organizations start with 14 days of Business.

Get started free