Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allows instrumentation to be disabled from a newrelic.config file. #2250

Merged
merged 12 commits into from Feb 16, 2024

Conversation

nrcventura
Copy link
Member

@nrcventura nrcventura commented Feb 16, 2024

BEGIN_COMMIT_OVERRIDE
feat: Allows instrumentation to be disabled from a newrelic.config file. Refer to our instrumentation configuration documentation for details. (#2250)
END_COMMIT_OVERRIDE

Thank you for submitting a pull request. Please review our contributing guidelines and code of conduct.

Description

Allows customers to control which assemblies and optionally classes should not be instrumented by specifying instrumentation ignore rules within a newrelic.config file.

Previous techniques required customers to directly remove or modify the installed instrumentation xml files. This new method should make it easier for these customers to upgrade the agent and keep certain instrumentations disables. It also enables the ability to have instrumentations disabled on a per application basis when a newrelic.config file is deployed with each application.

If you do not want a particular assembly instrumented you can add the following snippet to the instrumentation element in the newrelic.config file.

<rules>
  <ignore assemblyName="NameOfAssemblyToIgnore" />
</ rules>

The ignore rule instructs the profiler to not instrument any methods defined in the specified assembly. Methods defined in other assemblies will still be instrumented.

The ignore rule allows you to optionally define a class name. In the following example, only methods defined in MyNamespace.MyClass in the assembly MyAssembly will be ignored. Other methods in other classes both inside that assembly and within other assemblies will not be ignored by the profiler.

<rules>
  <ignore assemblyName="MyAssembly" className="MyNamespace.MyClass" />
</ rules>

More than one ignore rule can be specified. The following example disables both the Confluent Kafka and StackExchange Redis instrumentations.

<rules>
  <ignore assemblyName="Confluent.Kafka" />
  <ignore assemblyName="StackExchange.Redis" />
</ rules>

CAVEAT - Custom instrumentation added by using the Transaction or Trace attributes are not affected by this new configuration option. It only affects xml based custom instrumentation or the default instrumentation packaged with the .net agent.

Author Checklist

  • Unit tests, Integration tests, and Unbounded tests completed
  • Performance testing completed with satisfactory results (if required)

Reviewer Checklist

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (10af04d) 81.07% compared to head (3fa1d54) 81.09%.
Report is 21 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2250      +/-   ##
==========================================
+ Coverage   81.07%   81.09%   +0.01%     
==========================================
  Files         396      396              
  Lines       24713    24739      +26     
  Branches     2997     2999       +2     
==========================================
+ Hits        20036    20062      +26     
+ Misses       3890     3889       -1     
- Partials      787      788       +1     
Files Coverage Δ
...elic/Agent/Core/AgentHealth/AgentHealthReporter.cs 87.02% <100.00%> (+1.02%) ⬆️
...NewRelic/Agent/Core/Config/ConfigurationTracker.cs 100.00% <100.00%> (ø)
...c/Agent/Core/Configuration/DefaultConfiguration.cs 88.56% <100.00%> (+0.11%) ⬆️
.../Agent/Core/Configuration/ReportedConfiguration.cs 99.06% <100.00%> (+<0.01%) ⬆️
...c/Agent/NewRelic/Agent/Core/Metrics/MetricNames.cs 91.86% <ø> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@chynesNR chynesNR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Member

@tippmar-nr tippmar-nr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@nrcventura nrcventura merged commit 1632adb into main Feb 16, 2024
71 checks passed
@nrcventura nrcventura deleted the feature/disable-inst-by-config branch February 16, 2024 22:16
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.

None yet

4 participants