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

DEBUG-3176 DI: report an error when instrumenting a loaded file that is not in registry #4208

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

p-datadog
Copy link
Member

@p-datadog p-datadog commented Dec 9, 2024

What does this PR do?

Ruby stores the list of loaded files in $LOADED_FEATURES. Use this list to detect line probes that attempt to instrument files that have been loaded prior to code tracking being active, and report error to the user when instrumenting those files (since they won’t ever be instrumented in production).

Motivation:

Better diagnostics for DI.

Change log entry

Report instrumentation error in dynamic instrumentation when attempting to instrument line probes and the target file is loaded but not in code tracker registry.

Additional Notes:

The check can be expensive because it performs path suffix matching for potentially thousands of file paths corresponding to the loaded files.

How to test the change?

Unit tests are included

@p-datadog p-datadog requested a review from a team as a code owner December 9, 2024 15:00
Copy link

github-actions bot commented Dec 9, 2024

👋 Hey @p-datadog, please fill "Change log entry" section in the pull request description.

If changes need to be present in CHANGELOG.md you can state it this way

**Change log entry**

Yes. A brief summary to be placed into the CHANGELOG.md

(possible answers Yes/Yep/Yeah)

Or you can opt out like that

**Change log entry**

None.

(possible answers No/Nope/None)

Visited at: 2024-12-12 17:06:20 UTC

@pr-commenter
Copy link

pr-commenter bot commented Dec 9, 2024

Benchmarks

Benchmark execution time: 2024-12-09 15:34:41

Comparing candidate commit 1534132 in PR branch di-loaded-features with baseline commit 38fee9b in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.77%. Comparing base (38fee9b) to head (1534132).

Files with missing lines Patch % Lines
lib/datadog/di/instrumenter.rb 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4208      +/-   ##
==========================================
- Coverage   97.77%   97.77%   -0.01%     
==========================================
  Files        1357     1357              
  Lines       81973    81989      +16     
  Branches     4168     4173       +5     
==========================================
+ Hits        80149    80162      +13     
- Misses       1824     1827       +3     

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

@p-datadog p-datadog merged commit 65fb81d into master Dec 12, 2024
342 checks passed
@p-datadog p-datadog deleted the di-loaded-features branch December 12, 2024 17:07
@github-actions github-actions bot added this to the 2.9.0 milestone Dec 12, 2024
@p-datadog p-datadog mentioned this pull request Jan 15, 2025
@p-datadog
Copy link
Member Author

Note that this PR only applies to files loaded via require, not load. Files loaded via load are not added to $LOADED_FEATURES and thus cannot be identified by the check added in this PR.

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