Skip to content

Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABL…#5558

Closed
aitrics-ray wants to merge 4 commits intoDataDog:masterfrom
aitrics-ray:fix-disable-mongo-heartbeats-spans
Closed

Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABL…#5558
aitrics-ray wants to merge 4 commits intoDataDog:masterfrom
aitrics-ray:fix-disable-mongo-heartbeats-spans

Conversation

@aitrics-ray
Copy link
Copy Markdown
Contributor

@aitrics-ray aitrics-ray commented Apr 10, 2025

…ED is set to 'false'

What does this PR do?

This PR fixes an issue where MongoDB heartbeat traces were still being collected even when the environment variable DD_TRACE_MONGODB_HEARTBEAT_ENABLED was set to 'false'. The fix properly converts the string 'false' to a boolean value to ensure the heartbeat filtering works as expected.

Motivation

While testing MongoDB tracing, we discovered that setting DD_TRACE_MONGODB_HEARTBEAT_ENABLED=false didn't actually disable heartbeat traces. This was because the string value 'false' is truthy in JavaScript, causing the heartbeat filtering condition to fail. This fix ensures that MongoDB monitoring heartbeats can be properly excluded from traces when users want to reduce trace volume.
image

Plugin Checklist

Additional Notes

@aitrics-ray aitrics-ray requested review from a team as code owners April 10, 2025 07:23
@aitrics-ray aitrics-ray reopened this Apr 10, 2025
@aitrics-ray
Copy link
Copy Markdown
Contributor Author

This is a bug fix. Could someone with write access please add the semver-patch label to this PR? Thank you!

Comment thread packages/datadog-plugin-mongodb-core/src/index.js Outdated
@simon-id
Copy link
Copy Markdown
Member

Thank you for the PR, it indeed looks like we've made a mistake here. We'll do a first draft here, and once we agree on the changes, our team will recreate this PR, as the CI is not allowed to run on external contributions.

@aitrics-ray
Copy link
Copy Markdown
Contributor Author

@simon-id Thanks for the response! I understand. If you need any further assistance or if there's anything else I should do, please let me know.

Comment thread packages/datadog-plugin-mongodb-core/src/index.js Outdated
@simon-id
Copy link
Copy Markdown
Member

I'd say we should also write a test for this configuration, as we're clearly missing coverage if we didn't realize the feature was not working correctly. @tlhunter

@simon-id
Copy link
Copy Markdown
Member

ok fix is LGTM now, we should take over the rest and probably add a test

@simon-id
Copy link
Copy Markdown
Member

Cherrypicked your commits in #5562, let's move the discussion there

@simon-id simon-id closed this Apr 10, 2025
wconti27 added a commit that referenced this pull request Apr 10, 2025
* Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABLED is set to 'false'

Co-authored-by: aitrics-ray <kyounghwan.choi@aitrics.com>
Co-authored-by: William Conti <william.conti@datadoghq.com>
github-actions Bot pushed a commit that referenced this pull request Apr 10, 2025
* Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABLED is set to 'false'

Co-authored-by: aitrics-ray <kyounghwan.choi@aitrics.com>
Co-authored-by: William Conti <william.conti@datadoghq.com>
This was referenced Apr 10, 2025
github-actions Bot pushed a commit that referenced this pull request Apr 10, 2025
* Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABLED is set to 'false'

Co-authored-by: aitrics-ray <kyounghwan.choi@aitrics.com>
Co-authored-by: William Conti <william.conti@datadoghq.com>
@github-actions github-actions Bot mentioned this pull request Apr 10, 2025
bengl pushed a commit that referenced this pull request Apr 11, 2025
* Fix MongoDB heartbeat filtering when DD_TRACE_MONGODB_HEARTBEAT_ENABLED is set to 'false'

Co-authored-by: aitrics-ray <kyounghwan.choi@aitrics.com>
Co-authored-by: William Conti <william.conti@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants