dd-trace-rb icon indicating copy to clipboard operation
dd-trace-rb copied to clipboard

DEBUG-2334 dynamic instrumentation instrumenter component

Open p-datadog opened this issue 1 year ago • 3 comments

Change log entry

None, DI is not yet customer-visible.

What does this PR do?

This component instruments target code, meaning when target method or target line is invoked, the specified callback will be called with information about the program state at the target point (e.g. method parameters for method probe, local variables for line probe).

Motivation: Initial implementation of Ruby dynamic instrumentation.

Additional Notes: The instrumenter itself is under 300 lines. Most of the diff is in the test suite.

How to test the change? This PR includes unit tests, but a large part of instrumentation is dealing with code that is loaded after the instrumentation is installed (since much Ruby code is lazily loaded) and test coverage for this will be added later since it requires more DI components.

Unsure? Have a question? Request a review!

p-datadog avatar Oct 17 '24 18:10 p-datadog

Benchmarks

Benchmark execution time: 2024-10-17 20:01:02

Comparing candidate commit f904292776cb16d1082e50f06bcce17fa66a8fd5 in PR branch di-instrumenter with baseline commit 60febf8012de92758b85a7de0287342475ef0fb0 in branch master.

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

scenario:profiler - sample timeline=false

  • 🟥 throughput [-0.637op/s; -0.619op/s] or [-9.385%; -9.119%]

pr-commenter[bot] avatar Oct 17 '24 19:10 pr-commenter[bot]

This PR has some xit tests, I am planning on reviewing them to either make them work or delete them from the tree.

p-datadog avatar Oct 17 '24 21:10 p-datadog

Codecov Report

Attention: Patch coverage is 92.33716% with 40 lines in your changes missing coverage. Please review.

Project coverage is 97.79%. Comparing base (e8ef953) to head (8ef0a12). Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
lib/datadog/di/instrumenter.rb 83.49% 17 Missing :warning:
spec/datadog/di/instrumenter_spec.rb 96.29% 12 Missing :warning:
lib/datadog/di/probe.rb 57.14% 3 Missing :warning:
lib/datadog/di.rb 87.50% 2 Missing :warning:
spec/datadog/di/hook_line.rb 80.00% 1 Missing :warning:
spec/datadog/di/hook_line_basic.rb 80.00% 1 Missing :warning:
spec/datadog/di/hook_line_load.rb 80.00% 1 Missing :warning:
spec/datadog/di/hook_line_recursive.rb 88.88% 1 Missing :warning:
spec/datadog/di/hook_line_targeted.rb 80.00% 1 Missing :warning:
spec/datadog/di/hook_method.rb 92.30% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4012      +/-   ##
==========================================
- Coverage   97.82%   97.79%   -0.04%     
==========================================
  Files        1327     1337      +10     
  Lines       79698    80212     +514     
  Branches     3952     4013      +61     
==========================================
+ Hits        77968    78441     +473     
- Misses       1730     1771      +41     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 17 '24 21:10 codecov-commenter