elastic / elastic/apm-agent-nodejs

`error.context.{request,response}` for `@elastic/elasticsearch` instrumentation should use the current req/res

Open
#2,295 0 comments 0 reactions 0 assignees View on GitHub
agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

In the `@elastic/elasticsearch` instrumentation the APM error captured for an error on the 'response' event is setting `error.context.{request,response}` using the **current transaction's `.req` and `.res`, if any** (which is a fallback in `agent.captureError()`) rather than using the req/res objects for this Elasticsearch client request.

This ends up being very misleading in APM UI. For example, this shows an error in the Kibana APM UI (this is instrumentation of Kibana itself, which is why the transaction is for a request to "https://kibana..."). Because the `error.context` uses the top-level *transaction req/res*, the error summary shows a request with a "200 OK".

![Screen Shot 2021-08-20 at 11 12 59 AM](https://user-images.githubusercontent.com/46866/130279873-22c755cd-f9d5-4f16-a04b-408241ca16fd.png)

In this case, actually finding the parent ES and HTTP spans shows a "500" status code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.