spin icon indicating copy to clipboard operation
spin copied to clipboard

Provide a request ID as a header when the http trigger is triggered

Open mikkelhegn opened this issue 2 years ago • 7 comments

For logging and debugging purposes it's nice to be able to pre-fix logs with a request Id. Instead of having every component implement generating a request id, it would be nice if Spin could provide one as a header in the http request send to the component.

I don't know if other trigger types could make use of the same information, or if it already exists in the runtime!?!

mikkelhegn avatar Dec 06 '23 14:12 mikkelhegn

I don't think it currently exists. If we did this then yes, it would be good to make it available on all triggers, but only HTTP has the header concept: for other triggers, it would involve a change to the event payload, which is a WIT change.

A possible alternative way to do this would be to provide a new event_id host API, which any guest could call regardless of trigger type. This would be additive so no change to existing signatures. But if it were HTTP only then the header would work fine.

itowlson avatar Dec 06 '23 20:12 itowlson

I like the event_id idea. If the HTTP-trigger (or any trigger) could then implement it as part of a header or payload, would be up to the trigger.

mikkelhegn avatar Dec 06 '23 20:12 mikkelhegn

One thing to consider: we should probably provide a logging interface that it's not up to each component to log things in a uniform way. This would allow the Spin runtime and thus the end user to have more control over how logs are displayed.

rylev avatar Dec 07 '23 09:12 rylev

Could this be an option @rylev? https://github.com/dylibso/wasi-observe

mikkelhegn avatar Jan 10 '24 22:01 mikkelhegn

@calebschoepp is there any overlap with this request and current/forecasted telemetry work?

vdice avatar Mar 13 '24 16:03 vdice

My initial impression is that there isn't a ton of overlap here with WASI Observe. In the short to medium term WASI Observe is much more focused on tracing and metrics. I'm sure long-term WASI Observe will support the OTEL logging signal but it doesn't seem like a priority right now. @endocrimes please chime in if your perception is different.

As for overlap on the Spin specific observability work I've been doing: I also think there isn't really much overlap there.

As for participating in the discussion +1 to what Ryan said for making it not the responsibility of a component to log properly. I wonder if WASI Logging has anything that could help here.

calebschoepp avatar Mar 15 '24 18:03 calebschoepp

@mikkelhegn do you still feel like you have a need for this now that we have tracing?

calebschoepp avatar Aug 13 '24 22:08 calebschoepp