call setEventInfo() for custom events#175
Conversation
Custom events do not currently get a timestamp assigned, instead being logged with an unix epoch value. Create a custom event info, empty for now, so that we can correctly set the timestamp.
cf72d78 to
c09f717
Compare
dom96
left a comment
There was a problem hiding this comment.
Looks good to me. With the caveat that I don't have a lot of experience with this code path, but even if this doesn't work the change seems safe.
a-robinson
left a comment
There was a problem hiding this comment.
Yeah I don't know if this is what we'll want when we start wanting to provide info specific to a given custom event type, but this looks fine for getting the timestamp populated.
|
|
||
| auto& context = incomingRequest->getContext(); | ||
| KJ_IF_MAYBE(t, incomingRequest->getWorkerTracer()) { | ||
| t->setEventInfo(context.now(), Trace::CustomEventInfo()); |
There was a problem hiding this comment.
I think this code belongs inside the custom event callback, not here. That way the event can potentially decide what type of info to add. Additionally, you would have avoided the need for #177 as you could have this code execute after incomingRequest->delivered().
There was a problem hiding this comment.
Makes sense. I'll look into it tomorrow.
* Improve implementation of DOMException (cloudflare#159) * Implements API for connecting to TCP servers in workers * Adds TCP sockets sample implementing a Gopher proxy. * call setEventInfo() for custom events (cloudflare#175) * call setEventInfo() for custom events Custom events do not currently get a timestamp assigned, instead being logged with an unix epoch value. Create a custom event info, empty for now, so that we can correctly set the timestamp. * Update src/workerd/io/trace.h Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com> * fix context.now() when handling a trace The TraceCustomEventImpl is a custom event and when handling it the incomingRequests list is empty, causing getCurrentIncomingRequest() to fail. A new version of IoContext::now() is introduced for when we already have an incoming request available. * Add missing `locked` property to `ReadableStream` define * Add `CfHostMetadata` type parameter to `Request` override Allows the `HostMetadata` type parameter on `IncomingRequestCfProperties` to be specified with `Request` Co-authored-by: James M Snell <jsnell@cloudflare.com> Co-authored-by: Dominik Picheta <dominik@cloudflare.com> Co-authored-by: André Cruz <acruz@cloudflare.com> Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
Custom events do not currently get a timestamp assigned, instead being logged with an unix epoch value. Create a custom event info, empty for now, so that we can correctly set the timestamp.