-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Instrumentation for ES queries #86460
Comments
Pinging @elastic/apm-ui (Team:apm) |
Btw, maybe this should be handled in the Kibana ES client itself. I figure it might be useful for everyone. @elastic/kibana-core |
@dgieselaar we can add this request to the list of improvements in #78869. |
A slight terminology correction. It has to be in a separate async operation (i.e. a separate task on the libuv event loop), which is different than a callstack frame (a separate function call). |
Slightly gross, but we can also use the stack trace to get a name so we don't have to name our searches: That requires some knowledge about which specific function in the stack trace would be a good name for the search, which we can probably do for APM, but likely not in a way that it works for all plugins. We can use the parsed stack trace from the Span (again, maybe gross), or use a library to parse it. Sample set from browsing around (transaction name followed by span name):
|
For my understanding, will those values be assigned to span.name? @dgieselaar - do you think this improvement is generic enough to work well for ES node.js client? |
@alex-fedotyev I've been thinking about a slightly different approach that might be more generally useful: using the stack traces of all the items in the waterfall to get the most unique call site in a stack trace for a specific span and use that to display as a name. If I have some time I'll see if I can get a POC up and running just to see what the results are like, I don't think it would be that hard. |
Currently, when we use the ES client to search for apm events, the name of the ES span is the ES endpoint plus the indices that are being searched, e.g.
Elasticsearch: POST /apm-*/_search
. This is not very helpful when looking at the trace waterfall, because all ES spans created by APM searches look the same.What we can do is name our queries, e.g. require a query name when calling
apmEventClient.search
, and then create a span before callingesClient.search
. This will create a parent-child relationship between our span and the spans created by the ES client, and the waterfall will look like this:Currently it looks like a parent-child relationship is only created when the esClient.search call is not in the same frame as the one where the span is created. One thing that seems to be working is adding an
await Promise.resolve()
statement before. (see elastic/apm-agent-nodejs#1889).The text was updated successfully, but these errors were encountered: