Skip to content

Conversation

@lrafeei
Copy link
Contributor

@lrafeei lrafeei commented Nov 25, 2025

This PR adds a new feature to the agent: the ability to disable instrumentation for an entire group/package/module.

Use case: If instrumentation for Django is not desired, we would have to add 22 sections into the *.ini file, disabling each individual hook

[import-hook:django.core.handlers.base]
enabled = false
[import-hook:django.django.core.handlers.asgi]
enabled = false
[import-hook:django.core.handlers.wsgi]
enabled = false

et cetera.

With this feature, we can simply use

[import-hook:django]
enabled = false

And it will disable instrumentation for any Django hook.

Notes:

  • The grouping disable settings will take precedence over the individual import hook settings.
  • asyncio and the logging libraries do not have a separate grouping.

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

MegaLinter analysis: Error

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.76s
✅ MARKDOWN markdownlint 7 0 0 0 1.21s
❌ PYTHON ruff 949 1 1 0 0.92s
✅ PYTHON ruff-format 949 2 0 0 0.36s
✅ YAML prettier 15 0 0 0 1.38s
✅ YAML v8r 15 0 0 5.46s
✅ YAML yamllint 15 0 0 0.6s

Detailed Issues

❌ PYTHON / ruff - 1 error
::error title=Ruff (W293),file=tests/agent_features/test_configuration.py,line=984,col=1,endLine=984,endColumn=5::tests/agent_features/test_configuration.py:984:1: W293 Blank line contains whitespace
::error title=Ruff (W293),file=tests/agent_features/test_configuration.py,line=987,col=1,endLine=987,endColumn=5::tests/agent_features/test_configuration.py:987:1: W293 Blank line contains whitespace

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Nov 25, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.86%. Comparing base (4f5ef0d) to head (95517c2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1594      +/-   ##
==========================================
+ Coverage   81.84%   81.86%   +0.02%     
==========================================
  Files         207      207              
  Lines       24008    24008              
  Branches     3812     3812              
==========================================
+ Hits        19649    19654       +5     
+ Misses       3088     3084       -4     
+ Partials     1271     1270       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot removed the tests-failing Tests failing in CI. label Nov 25, 2025
@TimPansino
Copy link
Contributor

TimPansino commented Nov 26, 2025

This has always bothered me, and might be worth taking to Product.

The agents don't have any standard way of disabling instrumentation but our current one is very INI file-y. Not conducive to environment variables, or use with the newer TOML config file format. We have a section for TOML that does some translation to make this even possible to do.

I would be massively in favor of changing this, but would prefer something less coupled to the INI format. Ruby has one of the best formats I've seen that we're incredibly close to already which would make it easier to adopt.

instrumentation.memcache: auto
...
'Controls auto-instrumentation of dalli gem for Memcache at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'

They don't allow disabling sub-modules as far as I can tell, and have to add a new setting for every single library they instrument.

We already have instrumentation. settings that would likely need at least a tiny bit of reorganizing to make this fit, particularly the instrumentation.middleware.django settings. I think this would be a massive improvement, but would likely require us to make a ton of code changes to the import hooks.

@lrafeei
Copy link
Contributor Author

lrafeei commented Nov 26, 2025

This has always bothered me, and might be worth taking to Product.

The agents don't have any standard way of disabling instrumentation but our current one is very INI file-y. Not conducive to environment variables, or use with the newer TOML config file format. We have a section for TOML that does some translation to make this even possible to do.

I would be massively in favor of changing this, but would prefer something less coupled to the INI format. Ruby has one of the best formats I've seen that we're incredibly close to already which would make it easier to adopt.

instrumentation.memcache: auto
...
'Controls auto-instrumentation of dalli gem for Memcache at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'

They don't allow disabling sub-modules as far as I can tell, and have to add a new setting for every single library they instrument.

We already have instrumentation. settings that would likely need at least a tiny bit of reorganizing to make this fit, particularly the instrumentation.middleware.django settings. I think this would be a massive improvement, but would likely require us to make a ton of code changes to the import hooks.

Context for this PR: I put this out there because 1) we've had so many customers ask for something like this and 2) it would make some stuff I'm doing with Otel next quarter much easier but I wanted to give some time for everyone to think about how we'd implement something like this.

I'l look into Ruby's implementation for next steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants