#Is it possible to emit custom logs/spans that can be shown in the streaming dagger logs?

1 messages ยท Page 1 of 1 (latest)

agile night
#

I'd be interested in logging additional information during an execution that gets added to the streaming output of the logs and ideally the web.
Is this something that's really easy to do and I can't can't find the docs for? ๐Ÿ˜„
Thank you.

nocturne knot
#

yes, the SDK's have helper functions to get the current tracer and generate new spans that will get displayed in Dagger Cloud

#

I don't think that's documented yet cc @nocturne rampart

agile night
nocturne knot
#

yes, exactly

agile night
#

@nocturne knot thank you I'll take a look! ๐Ÿ˜„

nocturne rampart
#

We decided not to merge it as there will soon be a higher level API for this task

#

But maybe that PR is still helpful?

agile night
#

Depends how soon the higher level API appear I guess. ๐Ÿ™‚

#

Is it ok to abuse the trace api for logging?
Just an off the cuff feature request would be to be able to add leveled + structured logs. ๐Ÿ˜„

nocturne knot
agile night
#

@nocturne knot sorry to continue this thread, using spans for logs doesn't seem to be working really well for some reason.

func Log(ctx context.Context, msg string, args ...interface{}) {
    _, span := Tracer().Start(ctx, fmt.Sprintf(msg, args...))
    span.End()
}

I think this works for the most part but the spans seem to be in wrong places?
Most of my code should be correctly nested and passing contexts around, EXCEPT the LLM stuff.

The dag.LLM() doesn't seem to be accepting a context, so I'm not sure how it emits traces to the right place.