DEBUG-3176 DI: report an error when instrumenting a loaded file that is not in registry #4208
+45
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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