Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter out (or ignore) users from DataDog APM telemetry?

I'm trying to ignore traces of all requests from a specific user from our DataDog APM. Using dd-trace for Node.JS and also this plugin. I've been looking at the documentation on custom filters, but I can't get it to work. In the tracer, I have the following:

tracer.use('graphql', {
    source: true,
    signature: false,
    hooks: {
        // here, I add some tags, including the user ID 
        // so I tried: 
        if (user.id === 'id-to-ignore') {
            span.addTags({
                'ignoreThis': true,
            });
        }
        // but I can't filter by this tag either. 
        // Ideally, I would completely remove it here in the code,
        // but I could compromise on adding something we could filter in the DD APM UI
    }
}

Has anybody done this type of filtering successfully? Any ideas would be appreciated.

like image 632
Yuleidy Avatar asked Dec 16 '25 12:12

Yuleidy


1 Answers

It's possible to drop a trace directly in the tracer by using a tag. However, this tag needs to be set before any propagation occurs, so adding it in a hook won't work as it would be too late. Instead, it should be added to the active span as soon as the user ID is available like so:

const { MANUAL_DROP } = require('dd-trace/ext/tags')
const span = tracer.scope().active()

if (user.id === 'id-to-ignore') {
  span.setTag(MANUAL_DROP, true)
}
like image 106
rochdev Avatar answered Dec 19 '25 06:12

rochdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!