#OTEL Tracing

1 messages ยท Page 1 of 1 (latest)

wise flame
#

Moving [this thread](#general message) here

How can I get otel tracing to work? Here's what I have.

    ctx, span := otel.Tracer("ourskycustom").Start(k.runContext, "build-trace-start")
    defer span.End()

I tried last night with a tracer name of dagger sdk - can't recall exactly.
happy to DM you guys the dagger cloud trace, but I see nothing

mellow patio
#

@wise flame just to confirm, this code runs in an external dagger client, and not in a Dagger module, right?

#

(I'm guessing that's what you meant by "standard go sdk")

#
  • If your code is inside a Dagger module, then you get a convenience binding Tracer.Start(). It's just a convenience on top of standard otel library, but it's nice to use and that's what I use in the example I linked to you the other day
  • If your code is not inside a Dagger module, then you don't get the convenience, and I actually I don't know for sure if dagger run will set up the otel env variables for you that allow for the spans to go into Dagger Cloud. @oak jacinth or @nocturne gulch will know
#

(cc @solemn quest )

nocturne gulch
#

Yes -- in short, otel needs some OTEL_ env variables to know where to direct traces to.

IF dagger is the one starting your code (e.g. dagger call on your module), then it will set those up automatically for you

IF you're the one starting your code (e.g. using the Go SDK directly, then go run / go build'ing your code) then there's no way for dagger to pass those variables to you

I don't know if wrapping your invocation with a dagger run will set them up for you, but should be doable if not. @oak jacinth ?

mellow patio
#

would be pretty cool. Seems like a thing Alex would do ๐Ÿ™‚

#

@wise flame do you currently use dagger run?

nocturne gulch
mellow patio
nocturne gulch
#

I think so*

  • but Alex knows best
mellow patio
#

Ha ha you could actually just dagger run go test and just visualize your go tests in dagger cloud without even running a dagger engine ๐Ÿ˜›

nocturne gulch
#

Confirming it doesn't work by wrapping with dagger run -- maybe it's something doable on our end

wise flame
#

hi guys - no I dont use dagger run

#

we use a CLI directly - I know it's kind of an old pattern but refactoring to modules was tough for us, and lots of work. if it aintbroke.jpg

solemn quest
#

Oh I am sorry - my comments from before were assuming you are at least using dagger run.

Please note that dagger run != using dagger modules

dagger modules = dagger call
previous way to run with TUI = dagger run

Both of these should send traces automatically, the latter should not require any refactoring of your code.

mellow patio
#

@solemn quest both will send traces for work done in the engine, but Steven is asking specifically about "custom spans", which involves his client code sending custom otel spans directly. This works when the client code is itself running in a dagger function, but we figured out earlier in this thread that it does not work when it's running in an external client, which is the case here. Wrapping with dagger run does not currently do that, but we think it would be an easy feature to add - We're waiting for confirmation by Alex

solemn quest
#

Got it, yeah thanks for clarifying

mellow patio
#

Not exactly the simplest topic ๐Ÿ˜›

oak jacinth
#

(quick check in, off today ๐Ÿ‡จ๐Ÿ‡ฆ) - I think dagger run sets the OTEL_ env vars as appropriate, but your code will have to set up otel to export to it. You could confirm this with dagger run env

minor sequoia