The TrustPort Beacon Go SDK (beacon-go) provides high-velocity, asynchronous trace propagation with under 0.4% host CPU tax and nanosecond-level W3C header context propagation.
Add the Beacon Go package to your go.mod dependencies:
go get github.com/trustport/beacon-go@latestInitialize the SDK globally during startup and attach the Gin middleware to your router instance:
package main
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/trustport/beacon-go"
)
func main() {
// 1. Initialize Beacon Client
beacon.Init(beacon.Config{
IngestURL: "http://localhost:8443", // Or UK-1 Sovereign Zone Endpoint
APIKey: "tp_live_9f8a3c4e12",
ServiceName: "payment-gateway",
Environment: "production",
BatchSize: 500, // Asynchronous batch flushing
})
defer beacon.Close()
r := gin.Default()
// 2. Attach W3C Traceparent Middleware
r.Use(beacon.GinMiddleware("payment-gateway"))
// 3. Application Route Handler
r.POST("/api/v1/charge", func(c *gin.Context) {
ctx := c.Request.Context()
// Create a custom child span for database operation
span := beacon.StartSpan(ctx, "db.postgresql.charge_account")
// Perform work...
span.SetTag("customer_id", c.GetString("user_id"))
span.SetTag("currency", "USD")
span.End()
c.JSON(http.StatusOK, gin.H{
"status": "success",
"trace_id": beacon.TraceID(ctx),
})
})
r.Run(":8080")
}Use beaconfiber.New() for Go Fiber web servers:
app.Use(beaconfiber.Middleware("auth-service"))Wrap any standard HTTP handler with beaconhttp.Handler:
http.Handle("/api", beaconhttp.Handler(myHandler))Our senior architects can inspect your pipeline configuration.