Dd-trace-js: Issue setting up express plugin settings

Created on 7 Jun 2020  路  5Comments  路  Source: DataDog/dd-trace-js

Describe the bug
I am facing the following issues while trying to setup the express plugin -

  1. middleware:false does not seem to work.
  2. Blacklisting based on URL is not working. (I want to disable APM for /health/check )

Plugin settings -

    tracer.use('express', {
        blacklist: [/.*\/health\/check/],
        middleware: false,
    });

Screenshots -

  1. middleware still visible in DD monitoring dashboard -
    image

  2. Blacklisted URL is also visible -
    image

Environment

bug community integrations

All 5 comments

It will be great if someone can guide me on this. 馃檹

Can you share the top of the entry point file where the tracer is imported/initialized? Usually when the configuration is ignored it's because of an ordering issue, for example something being imported before the tracer is initialized. There was however a similar report for the graphql plugin and I'm starting to wonder if there is a regression in the instrumenter. Confirming that the order is correct would help validate that.

@kumaraksi - going to close this out for now, if you have any questions and want to dig further please reach out.

hi @rochdev

i'm facing the same issue right now. you can find the entry file of my service is like this.
these lines are even added before all the imports

'use strict';

const tracer = require('dd-trace').init({
    plugins: false,
    startupLogs: true,
    debug: DD_DEBUG_ENABLED,
    runtimeMetrics: DD_RUNTIME_METRICS_ENABLED,
    service: DD_SERVICE,
    env: DD_ENV,
    analytics: true
});
tracer.use('express', {
    middleware: false,
    blacklist: ['/health/check']
});

// all the imports go after this lines

I have managed to fix it by a very simple change. setting the plugins: false
From what i see is that by default the library is loading the plugins asynchronously which might override the configs for the plugin and setting them to the default ones

below is the code that made it to work

'use strict';

const tracer = require('dd-trace').init({
    plugins: false,
    startupLogs: true,
    debug: DD_DEBUG_ENABLED,
    runtimeMetrics: DD_RUNTIME_METRICS_ENABLED,
    service: DD_SERVICE,
    env: DD_ENV,
    analytics: true
});
tracer.use('express', {
    plugins: false, // here's the change that made it work
    middleware: false,
    blacklist: [/.*\/health\/check/] // and this one also
});

// all the imports go after these lines
Was this page helpful?
0 / 5 - 0 ratings

Related issues

pauldraper picture pauldraper  路  6Comments

TheComfyChair picture TheComfyChair  路  5Comments

edrich-xendit picture edrich-xendit  路  3Comments

josephsofaer picture josephsofaer  路  5Comments

lancedikson picture lancedikson  路  6Comments