(feat) Set context and body for log records emitted by instrumentation#282
(feat) Set context and body for log records emitted by instrumentation#282gfoidl wants to merge 1 commit into
Conversation
… potentially link to traces
|
Thanks for putting this together! Regarding body - My hesitation is also about layer and scope - I'll open an issue in semantic-conventions to discuss the body question more broadly. Since there's no precedent or guidance on this, I think it's worth getting an answer there before any instrumentation adopts a pattern. I'll link it back here once it's up, and would love your input in that discussion. Regarding context - The reason these events are not associated with spans is that their callsites (window error handler, PerformanceObserver, history wrappers, DOM listeners) all fire from the platform when there is no active span. The only time the active context will work is for events emitted from wrapped callbacks (e.g. for the xhr/fetch instrumentations). If you have a specific use case in mind for linking events to span context, please open an issue and we can discuss it there. |
|
Thanks for your coherent insight -- makes all sense, and also thanks for putting this to the SIG! ad context: uh, I really missed that part from reading the coce, so this should be removed from this PR. |
Which problem is this PR solving?
From Grafana:

There's no body in the log records, so it's hard to spot which instrumenation emitted the log. This is only seeable in the details.
Short description of the changes
Type of change
The
bodyis set on the emitted log records, as well thecontext.active()set, so that there's a potential link to traces in order to make observability more seamless.With this change it looks in Grafana like

An alternative to this PR could be using a transformer in the OTel-collector, but this is not very user-friendly.
Also when the setup doesn't use OTel-collector the logs will look empty again.
How Has This Been Tested?
Added assertions to the unit tests, and manual verification.
Checklist: