# DB2 spans for Node Js application

**URL:** <https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [January 25, 2022, 10:19am UTC](https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327 "2022-01-25T10:19:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![satpreetsn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satpreetsn/32/100828_2.png) [@satpreetsn](https://discuss.elastic.co/u/satpreetsn)\
**Post date:** [January 25, 2022, 10:19am UTC](https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327/1 "2022-01-25T10:19:04Z")

</div>

Hi,

Nodejs apm agent doesn't show the database query in spans. Database we use is db2 and connect using ibm-db2 dependency for nodejs. Can anyone suggest if any specific flags need to be passed to intialise database query spans?

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [January 25, 2022, 9:46pm UTC](https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327/2 "2022-01-25T21:46:07Z")

</div>

Hi @satpreetsn.

Are you using this npm package: [ibm\_db - npm](https://www.npmjs.com/package/ibm_db) ?  
The Node.js APM agent doesn't currently have an instrumentation for the `ibm_db` package, so it expected that it isn't automatically picking up DB query details.

Are you manually starting APM spans (via `apm.startSpan(...)` or similar)? If so, and if you have access to the database query statement, then you can use something like:

```auto
var span = apm.startSpan(...)
span.setDbContext({type: 'db2', statement: '... query statement here ...'})

```

Note, however, that **`span.setDbContext()` is an internal/undocumented method that can change.**

---

<div class="post-metadata">

**Author:** ![satpreetsn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satpreetsn/32/100828_2.png) [@satpreetsn](https://discuss.elastic.co/u/satpreetsn)\
**Post date:** [January 27, 2022, 9:51am UTC](https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327/3 "2022-01-27T09:51:44Z")

</div>

I see ibm\_db driver uses underlying ODBC drivers. Can we have any instrumentation for ODBC drivers?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 24, 2022, 9:51am UTC](https://discuss.elastic.co/t/db2-spans-for-node-js-application/295327/4 "2022-02-24T09:51:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
