Browser
Server
Native OpenTelemetry
Fullstack Frameworks
Overview
Self Host & Local Dev
Menu
Manual Go Tracing Quick Start
Learn how to set up highlight.io tracing for your Go application.
1
Configure client-side Highlight. (optional)
If you're using Highlight on the frontend for your application, make sure you've initialized it correctly and followed the fullstack mapping guide.
2
Install the Highlight Go SDK.
Install the highlight-go package with go get.
go get -u github.com/highlight/highlight/sdk/highlight-go3
Initialize the Highlight Go SDK.
highlight.Start starts a goroutine for recording and sending backend traces and errors. Setting your project id lets Highlight record errors for background tasks and processes that aren't associated with a frontend session.
import ( "github.com/highlight/highlight/sdk/highlight-go" ) func main() { // ... highlight.SetProjectID("<YOUR_PROJECT_ID>") highlight.Start( highlight.WithServiceName("my-app"), highlight.WithServiceVersion("git-sha"), ) defer highlight.Stop() // ... }4
Wrap your code using the Go SDK.
By wrapping your code with StartTrace and EndTrace, the Highlight Go SDK will record a span. You can create more child spans using the child context or add custom attributes to each span.
import ( "github.com/highlight/highlight/sdk/highlight-go" "go.opentelemetry.io/otel/attribute" ) func functionToTrace(ctx context.Context, input int) { s, childContext := highlight.StartTrace(ctx, "functionToTrace", attribute.Int("custom_property", input)) // ... anotherFunction(childContext) // ... highlight.EndTrace(s) } func anotherFunction(ctx context.Context) { s, _ := highlight.StartTrace(ctx, "anotherFunction") // ... highlight.EndTrace(s) }5
Verify your backend traces are being recorded.
Visit the highlight traces portal and check that backend traces are coming in.