Go Integration
Send structured logs from Go applications to LogTide using the official Go SDK.
Send structured logs from any Go application to LogTide using the official SDK. It handles batching, retries, and circuit breaking automatically.
Installation
go get github.com/logtide-dev/logtide-sdk-go
Requires Go 1.23+.
Quick Start
package main
import (
"context"
logtide "github.com/logtide-dev/logtide-sdk-go"
)
func main() {
flush := logtide.Init(logtide.ClientOptions{
DSN: "https://[email protected]",
Service: "my-service",
Environment: "production",
})
defer flush()
logtide.Info(context.Background(), "Application started", map[string]any{
"version": "1.2.3",
})
}
Configuration
opts := logtide.NewClientOptions()
opts.DSN = "https://[email protected]"
opts.Service = "my-service"
opts.Release = "v1.2.3"
opts.Environment = "production"
opts.Tags = map[string]string{"region": "eu-west-1"}
client, err := logtide.NewClient(opts)
if err != nil {
log.Fatal(err)
}
defer client.Close()
HTTP Middleware
The built-in net/http middleware handles scope isolation, HTTP tagging, and breadcrumbs per request:
import lnethttp "github.com/logtide-dev/logtide-sdk-go/integrations/nethttp"
mux := http.NewServeMux()
http.ListenAndServe(":8080", lnethttp.Middleware(mux))
OpenTelemetry
Trace and span IDs are extracted automatically from any active OTel span in the context:
ctx, span := tracer.Start(ctx, "process-order")
defer span.End()
// trace_id and span_id included automatically
client.Info(ctx, "Order processed", map[string]any{"order_id": id})
Graceful Shutdown
// Global Init pattern
flush := logtide.Init(opts)
defer flush() // flushes all buffered entries
// Explicit client pattern
client, _ := logtide.NewClient(opts)
defer client.Close()
Next Steps
- Go SDK reference — full API documentation
- Docker Integration — container deployment
- Kubernetes Integration — cluster logging
Frequently Asked Questions
How do I send Go application logs to LogTide?
Run go get github.com/logtide-dev/logtide-sdk-go, then call logtide.Init() with your DSN and service name. Use logtide.Info(), logtide.Error(), and similar functions, and defer the returned flush function to ensure buffered logs are flushed on shutdown.
Does the Go SDK support structured log metadata?
Yes. Every log call accepts a map[string]any as its third argument, which is sent as structured JSON metadata alongside the service name, message, and log level.
How do I add LogTide logging to a Go HTTP server without changing every handler?
Use the built-in net/http middleware by wrapping your mux with lnethttp.Middleware(mux). It handles scope isolation, HTTP tagging, and breadcrumbs per request automatically.
Does LogTide integrate with OpenTelemetry in Go?
Yes. If an active OpenTelemetry span is present in the context passed to a log call, the SDK automatically extracts and attaches the trace_id and span_id to the log entry.