elastic / elastic/apm-agent-nodejs

`request` method of other library is picked up by `http` instrumentation

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

Description

During https://github.com/elastic/apm-agent-nodejs/issues/1781 I also stumbled over the following behavior:

When wrapping a function called `request` the `http` instrumentation seems to get triggered:

```js
var originalRequest = prisma.fetcher.request
var newRequest = async function(object) {
var span = apm.startSpan('Query Engine (prisma.fetcher.request)')
var result = await originalRequest.call(this, object)
span.end()
return result
}
prisma.fetcher.request = newRequest
```

leads to this debug output:

```
no active transaction found - cannot build new span
intercepted call to http.request { id: null }
```

and quite some confusion.

The workaround or solution is to configure the instrumentation to ignore `http`: `disableInstrumentations: ['http']` in `apm.start()`.

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.