All Integrations
Languagesgo.atatus.net/tigerops SDK

Go Integration

Low-overhead Go instrumentation with goroutine metrics, GC stats, and distributed trace propagation. Works with Gin, Echo, Chi, and standard net/http.

Setup

How It Works

01

go get the SDK

Run go get go.atatus.net/tigerops. The SDK is a thin wrapper over the OpenTelemetry Go SDK with TigerOps-specific exporters and Go runtime metrics collection built in.

02

Initialize in main()

Call tigerops.Init() at the start of main() before creating your HTTP server. The init function configures the OTLP exporter, starts the Go runtime metrics goroutine, and registers the global tracer provider.

03

Add Middleware

Wrap your HTTP router with the TigerOps middleware for your framework (Gin, Echo, Chi, or net/http). Each request becomes a trace span with HTTP method, path, status code, and duration.

04

Goroutine & GC Metrics Flow In

TigerOps begins collecting runtime.NumGoroutine, GC pause times, heap allocations, and OS thread counts. These are correlated with request traces in your TigerOps service dashboard.

Capabilities

What You Get Out of the Box

Goroutine Count & Leaks

Track goroutine count over time and detect goroutine leaks. TigerOps alerts when goroutine count grows unboundedly and provides a goroutine profile snapshot for investigation.

GC Pause & Heap Stats

GC pause duration (stop-the-world and concurrent), heap in-use, heap objects, and next GC threshold from runtime.MemStats. Correlate GC pauses with request latency spikes.

Context Propagation

Full W3C trace context propagation through Go context.Context. TigerOps middleware injects and extracts traceparent headers for correct distributed trace assembly across services.

HTTP Client Tracing

Wrap http.Client with TigerOps transport to trace all outbound HTTP requests. Each request becomes a child span with the URL, method, status, and duration.

Database Driver Spans

Automatic spans for database/sql, pgx, gorm, and mongo-go-driver. Each query includes the normalized SQL text and connection pool wait time as span attributes.

Custom Metrics via OTEL

Use the OpenTelemetry Go metrics API to record custom business metrics from your Go code. TigerOps' OTLP endpoint accepts any OTEL metric type: counters, histograms, and gauges.

Configuration

go get + Middleware Example

Initialize TigerOps in main() and add middleware to your router.

main.go
# Install the TigerOps Go SDK
go get go.atatus.net/tigerops@latest
go get go.atatus.net/tigerops/middleware/gin@latest

# main.go — Gin example
package main

import (
    "context"
    "log"
    "net/http"

    "github.com/gin-gonic/gin"
    "go.atatus.net/tigerops"
    tigergin "go.atatus.net/tigerops/middleware/gin"
)

func main() {
    // Initialize TigerOps — must be called first in main()
    shutdown, err := tigerops.Init(
        tigerops.WithServiceName("order-service"),
        tigerops.WithEnvironment("production"),
        // API key is read from TIGEROPS_API_KEY env var by default
    )
    if err != nil {
        log.Fatal(err)
    }
    defer shutdown(context.Background())

    r := gin.New()

    // Add TigerOps middleware — traces all requests automatically
    r.Use(tigergin.Middleware())

    r.GET("/orders/:id", func(c *gin.Context) {
        ctx := c.Request.Context()

        // Create a custom child span
        ctx, span := tigerops.StartSpan(ctx, "fetch-order")
        defer span.End()

        order, err := db.GetOrder(ctx, c.Param("id"))
        if err != nil {
            span.RecordError(err)
            c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
            return
        }

        c.JSON(http.StatusOK, order)
    })

    r.Run(":8080")
}
FAQ

Common Questions

Does TigerOps support Go modules and the latest Go versions?

Yes. The TigerOps Go SDK supports Go 1.21+ and follows Go module versioning. It is tested against the latest stable and RC Go releases. The SDK has no cgo dependencies and compiles for all GOOS/GOARCH combinations.

Can I use TigerOps with existing OpenTelemetry Go instrumentation?

Yes. tigerops.Init() registers a global TracerProvider that is compatible with the standard go.opentelemetry.io/otel API. Any existing OTel instrumentation in your codebase will automatically use the TigerOps exporter after calling Init().

Does the SDK work with goroutine-heavy workloads like worker pools?

Yes. TigerOps propagates trace context through Go context.Context, which is the standard way to propagate context in Go. As long as your worker pool passes the context through, child spans will correctly link to the parent request span.

How does TigerOps handle high-cardinality routes in Go HTTP routers?

TigerOps reads the route template (e.g., /users/{id}) from the router middleware rather than the raw URL path. For Gin, Echo, and Chi, the route pattern is extracted automatically. This prevents high-cardinality metric explosions from parameterized routes.

Can I get continuous profiling for Go applications in TigerOps?

Yes. TigerOps supports Go continuous profiling via pprof integration. Enable it with tigerops.EnableProfiling() and TigerOps will periodically collect CPU, heap, and goroutine profiles and correlate them with trace latency events in the TigerOps UI.

Get Started

Idiomatic Go Observability With Zero Overhead

Goroutine metrics, GC analysis, and distributed traces. Designed for the way Go applications are actually built.