package main
import (
"context"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/sdk/trace"
)
func main() {
ctx := context.Background()
exporter, _ := otlptracehttp.New(ctx,
otlptracehttp.WithEndpoint("localhost:9411"),
otlptracehttp.WithInsecure(),
)
tp := trace.NewTracerProvider(
trace.WithBatcher(exporter),
)
otel.SetTracerProvider(tp)
tracer := otel.Tracer("my-service")
_, span := tracer.Start(ctx, "llm_call")
defer span.End()
span.SetAttributes(
attribute.String("model", "gpt-4"),
attribute.Float64("cost_usd", 0.003),
)
}