-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exclude the HTTP span under an Elasticsearch span #2000
Comments
This was discussed on the APM Agents call yesterday. The pretty strong consensus seemed to be to not emit HTTP spans (or whatever other transport span) underneath higher-level instrumentation spans: e.g. no HTTP span underneath an SQS span, no HTTP span underneath an Elasticsearch span. Also this note from eyal:
|
How do we capture retries if the HTTP span is dropped? |
+1 on this for Kibana's usage. We'd like to start enabling our support team to use APM instrumentation to debug performance problems and I think this duplication creates confusing noise.
Could we add a |
I'll ask the APM group. I don't see any current apm-server intake fields, no ECS http fields that could easily hold this value. |
Note to self: because a span synchronously created under a current span (e.g. the HTTP span under an ES span) currently isn't set as a child might complicate implementation of this. If we had the child relationship (as we eventually want), then the implementation could just be something like the Python agent's |
Now that #2181 is in we have the parent/child relationship we need. Implementing this (and #2125) should be via implementing exit span support and marking ES spans as exit spans. Need to make sure context propagation still works. I'm not sure if that'll be via having the ES instrumentation add the trace-context headers, or by keeping that in HTTP instrumentation, even though a span isn't created there. I think probably the latter. The handling in http-shared.js already handles propagating trace-context headers even if Also, perhaps think ahead about compressed span handling implications. |
… elided Elasticsearch (ES) client spans are no marked as exit spans, so their HTTP child spans are now no longer generated per spec: https://github.com/elastic/apm/blob/main/specs/agents/tracing-spans.md#exit-spans Some HTTP context has been added to ES spans: - span.context.http.status_code - span.context.http.response.encoded_body_size Closes: #2000 Closes: #2484
…w elided (#2557) feat: mark Elasticsearch spans as exit spans; HTTP child spans are now elided Elasticsearch (ES) client spans are no marked as exit spans, so their HTTP child spans are now no longer generated per spec: https://github.com/elastic/apm/blob/main/specs/agents/tracing-spans.md#exit-spans Some HTTP context has been added to ES spans: - span.context.http.status_code - span.context.http.response.encoded_body_size Closes: #2000 Closes: #2484
Note that I haven't pursued the "how to track retries". We discussed it at an APM Agents call (2022-02-01). There isn't a currently suitable ECS field for this. I considered adding a span label for this, but it would be first case of any Node.js APM agent instrumentation adding span labels automatically -- I'm not sure if span labels should remain the domain of the user. User code (e.g. Kibana code) should be able to add an ES Client "response" handler to add a label to the client.on('response', (_err, result) => {
// Obviously missing defensive guards here.
apm.currentSpan.setLabel('attempts', result.meta.attempts, false)
}) |
From discussion on today's apm-agent-nodejs call and from elastic/apm#420 we think the HTTP span "under" an Elasticsearch (ES) span from instrumentation of the "elasticsearch" and "@elastic/elasticsearch" modules should be excluded. The ES span is an "exit" span, and arguably the HTTP request it makes is an implementation detail. As well, eliding that span would make breakdown metrics much more useful/realistic. (FWIW, it would also side-step the current issue with the HTTP span being a sibling of, rather than a child of, the ES span for the instrumentation of the newer "@elastic/elasticsearch" client.)
From memory (though might be nice to confirm), the Python agent excludes the HTTP span (via
leaf=True
in the code). I recall one other language agent optionally including the HTTP span, but I think it was off by default.The text was updated successfully, but these errors were encountered: