should events on an outgoing HTTP request (ClientRequest
) object be bound to the Span context for that request?
#3734
Labels
agent-nodejs
Make available for APM Agents project planning.
In a recent private thread, there was a question about whether
span.setLabel(...)
could be used to add data to the span for an outgoing HTTP request. The issue currently is that there is no place for user code making an outgoing HTTP request to get a reference to the span for that HTTP request. I.e. there is no point in user code whereapm.currentSpan
returns that active span.That's because (in "http-shared.js") we don't bind the ClientRequest event emitter to the run-context for that span. We could do so:
With that change, handlers for the events on
http.ClientRequest
-- e.g. "socket", "finish" -- would have the currentSpan set. Theexamples/trace-http-request.js
shows an example.That results in the following span being sent:
Notice the added "body" label (called "tags" in the intake API), added via
span.setLabel("body", data)
.The question is should we do this? I'm adding this now, not because there is a strong need, but because I'd dug around a little bit and didn't want to lose the context.
The text was updated successfully, but these errors were encountered: