OpenTelemetry Config Generator
Generate a working OpenTelemetry configuration for your language and framework. Works with any OTel-compatible backend.
Works with any OpenTelemetry-compatible backend
package main
import (
"context"
"log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
)
func initTracer() func() {
ctx := context.Background()
exporter, err := otlptracehttp.New(ctx,
otlptracehttp.WithEndpoint("app.tracekit.dev"),
)
if err != nil {
log.Fatalf("failed to create exporter: %v", err)
}
tp := trace.NewTracerProvider(
trace.WithBatcher(exporter),
trace.WithSampler(trace.TraceIDRatioBased(1)),
trace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("my-service"),
)),
)
otel.SetTracerProvider(tp)
return func() { _ = tp.Shutdown(ctx) }
}How It Works
This generator creates a production-ready OpenTelemetry configuration for your chosen language and framework. It includes SDK initialization, exporter setup, resource attributes, and sampling configuration.
SDK tab: Contains the language-specific initialization code you add to your application. The .env tab shows environment variables that work as an alternative or supplement to code-based configuration.
The generated configuration uses the OTLP HTTP exporter, which is compatible with TraceKit, Jaeger, Grafana Tempo, and any other OpenTelemetry-compatible backend.
Monitor real traces in production -- Start free with TraceKit