Fiber Integration
Instrument Go Fiber applications with one middleware registration. Low-overhead request lifecycle tracing, route-level spans, GORM query traces, and fasthttp connection pool metrics — built for Fiber's performance-first design.
How It Works
Install the Go Module
Run go get github.com/tigerops/tigerops-go/fiber. The module is compatible with Fiber v2 and v3 and includes a Fiber-native middleware adapter, GORM and pgx plugin, and async OTLP HTTP exporter tuned for Fiber's fasthttp engine.
Register the Middleware
Call app.Use(tigeropsfiber.Middleware()) before your routes. The middleware adapts Fiber's fasthttp context to the standard context.Context required by OpenTelemetry. No fasthttp-specific changes to your handler code are needed.
Configure via Environment
Set TIGEROPS_API_KEY, TIGEROPS_SERVICE_NAME, and TIGEROPS_ENVIRONMENT. TigerOps reads them at Init() time. Fiber's built-in EnvVar config source is also supported. The functional options API allows programmatic configuration at startup.
Spans & Go Runtime Metrics
TigerOps immediately captures Fiber route handler spans, database query traces, outbound HTTP client spans, goroutine counts, heap allocation rates, GC pause durations, and fasthttp connection pool saturation metrics.
What You Get Out of the Box
Low-Overhead Fiber Middleware Tracing
The TigerOps Fiber middleware is built on fasthttp primitives to match Fiber's zero-allocation design. Span creation uses a sync.Pool to avoid heap allocations per request. Overhead is under 5 microseconds at 100% sampling on the Fiber benchmark suite.
Route-Level Handler Spans
Each Fiber route handler generates a child span with the registered route pattern (e.g. /orders/:id), HTTP method, response status, and content length. Named route groups appear as prefixes in the route attribute, preventing cardinality explosion.
GORM & pgx Query Tracing
Register the TigerOps GORM plugin or pgx middleware to trace all database queries. Spans include normalized SQL, table names, execution time, and row counts. pgx batch queries appear as a single span with a batch_size attribute.
Fiber Error Handler Spans
Custom Fiber error handlers are instrumented to capture the error type, HTTP status, and stack trace in the active span before the error response is written. Panic recovery in handlers produces an error span tagged with the recovered value.
fasthttp Connection Pool Metrics
TigerOps reports fasthttp server-level metrics: open connection count, idle connection count, request queue length, and max concurrent requests. These metrics help identify connection saturation before it impacts response latencies.
Go Runtime & GC Telemetry
Continuous Go runtime metrics include goroutine count, heap in-use bytes, stack in-use bytes, GC cycle frequency, GC pause p50/p99, and GOMAXPROCS utilization. Metrics are exported every 30 seconds via the OTLP metrics endpoint.
Install & Initialize
One go get and one app.Use() call. Full Fiber observability with zero allocation overhead.
# Install the TigerOps Fiber module
go get github.com/tigerops/tigerops-go/fiber
# Set environment variables
export TIGEROPS_API_KEY="your-api-key"
export TIGEROPS_SERVICE_NAME="my-fiber-app"
export TIGEROPS_ENVIRONMENT="production"
// main.go
package main
import (
"github.com/gofiber/fiber/v2"
tigerops "github.com/tigerops/tigerops-go"
tigeropsfiber "github.com/tigerops/tigerops-go/fiber"
tigerormgorm "github.com/tigerops/tigerops-go/gorm"
"gorm.io/gorm"
"go.opentelemetry.io/otel/attribute"
)
func main() {
tp := tigerops.Init(
tigerops.WithServiceName("my-fiber-app"),
tigerops.WithEnvironment("production"),
)
defer tp.Shutdown(context.Background())
db, _ := gorm.Open(postgres.Open(dsn))
db.Use(tigerormgorm.Plugin())
app := fiber.New(fiber.Config{
ErrorHandler: tigeropsfiber.ErrorHandler,
})
app.Use(tigeropsfiber.Middleware())
app.Get("/orders/:id", func(c *fiber.Ctx) error {
ctx := tigeropsfiber.ContextFromFiber(c)
span := tigerops.SpanFromFiber(c)
span.SetAttributes(attribute.String("order.id", c.Params("id")))
var order Order
db.WithContext(ctx).First(&order, c.Params("id"))
return c.JSON(order)
})
app.Listen(":8080")
}Common Questions
Which Fiber and Go versions are supported?
Fiber v2.x and v3.x are both supported. Go 1.21 and later are required. The module uses Go generics for the span context adapter, which requires Go 1.21+. Fiber apps running on Alpine Linux and distroless containers are fully compatible.
How does TigerOps bridge Fiber's fasthttp context with OpenTelemetry?
Fiber uses fasthttp which does not use the standard context.Context. TigerOps stores the active span in a Fiber Locals key and provides helpers like tigerops.SpanFromFiber(c) and tigerops.ContextFromFiber(c) to retrieve a standard context for use in GORM and HTTP client calls.
Does TigerOps support Fiber's built-in request ID middleware?
Yes. If you register Fiber's requestid middleware before the TigerOps middleware, the request ID is automatically added as a span attribute (http.request_id). You can also configure TigerOps to generate and inject its own trace ID as the X-Request-ID header.
How does tracing work with Fiber prefork mode?
In prefork mode, each forked process initializes its own TigerOps tracer provider. Spans from all prefork children are exported to the same OTLP endpoint and correlated by service name and instance ID. The process PID is added as a span resource attribute.
Can I sample only slow requests above a threshold?
Yes. TigerOps supports a threshold-based tail sampler. Set TIGEROPS_TAIL_SAMPLE_THRESHOLD_MS=200 to always sample requests slower than 200ms regardless of the head sampling rate. Errors are always sampled at 100% regardless of latency.
Full Fiber Observability in One Go Module
Request lifecycle spans, GORM traces, fasthttp pool metrics, and Go runtime telemetry — built for Fiber's zero-allocation philosophy.