#How to work with OTEL tracer and custom spans in the Go SDK

1 messages · Page 1 of 1 (latest)

robust goblet
#

I'm trying to implement custom spans using the Go SDK. From other posts, it seems like the following ought to work

func build() {
  tr := dagger.Tracer()
  ctx, span := tr.Start(context.Background(), "build")
  defer span.End()

  ...
}

However, I am not seeing any indication of the custom spans in the CLI or Dagger UI

oblique warren
#

I recall we ran into this not so long about the telemetry.Tracer or dagger.Tracer not being able to add spans to the current dagger call. In this case since it's via SDK, there's no dag.Tracer we can use 🤔

robust goblet
#

because that is technically in the dagger cli? and maybe we need to make the link with TRACEPARENT manually?

oblique warren
#

dagger run is the one that initially creates the trace and sets the TRACEPARENT variable

spice drift
#

you'll need a dagger.io/dagger/telemetry.Init() call in there somewhere (like func main()) to set up the OTel exporters and such

robust goblet
#

I added the following, and pass the otelCtx to the tr.Start(...) but still see nothing that indicates it is working

otelCtx := telemetry.Init(context.Background(), telemetry.Config{Detect: true})