#otel go plumbing
1 messages ยท Page 1 of 1 (latest)
easiest way is to use github.com/dagger/otel-go since it automates all the setup. in main(), do ctx = daggerotel.InitEmbedded(ctx, nil) and defer daggerotel.Close(), from then on just use otel sdk "like normal"
Thanks. What does the Embedded mean in this context?
FYI this is what the LLM landed on, after me telling it to simplify several times:
import (
telemetry "github.com/dagger/otel-go"
)
func main() {
ctx := telemetry.Init(context.Background(), telemetry.Config{Detect: true})
defer telemetry.Close()
}
eh that's probably fine, InitEmbedded might be something we can/should just deprecate at this point. it calls Init internally with subtly different logic for detection, which might have been made redundant when we added $OTEL_EXPORTER_OTLP_TRACES_LIVE - pausing explanation there assuming you'd like to bail out of the rabbit hole ๐
@bronze moat also for starting a new thread, should I create my own Tracer() wrapper function?
currently:
daggerotel.Tracer(ctx, "my-thing").Start(ctx, "my span')
possibly wrapped by: myTracer(ctx).Start(ctx, "my span")
which kind of makes me want to collapse further to startSpan(ctx, "my span") ๐