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-3182 Rework DI loading #4239

Merged
merged 18 commits into from
Jan 9, 2025
Merged

DEBUG-3182 Rework DI loading #4239

merged 18 commits into from
Jan 9, 2025

Conversation

p-datadog
Copy link
Member

What does this PR do?

This PR separates the part of DI that is required for code tracker (which is the code tracker itself and the DI.current_component group of methods, plus exception classes) to be self-contained. Currently in master loading datadog/di/init would bring in datadog/di as well which is too much (for example, that would cause DI to attempt to load ActiveRecord contrib, which is definitely not the right time for it).

Motivation:

Ensuring DI code tracker is loaded early without causing the rest of dd-trace-rb to be loaded early.

Change log entry

Yes: Improved early loading mechanism of dynamic instrumentation (datadog/di/init).

Additional Notes:

While this PR changes the behavior of datadog/di/init, this behavior has not yet been documented anywhere and should not be used by customers.

How to test the change?

Integration tests specifically for datadog/di/init will be added in a follow-up PR. The existing unit tests verify that basic DI functionality continues to operate correctly.

@p-datadog p-datadog marked this pull request as ready for review December 19, 2024 14:52
@p-datadog p-datadog requested a review from a team as a code owner December 19, 2024 14:52
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Dec 19, 2024

Datadog Report

Branch report: di-loading
Commit report: a482c0f
Test service: dd-trace-rb

✅ 0 Failed, 22113 Passed, 1476 Skipped, 5m 57.55s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Dec 19, 2024

Benchmarks

Benchmark execution time: 2025-01-09 06:59:09

Comparing candidate commit a482c0f in PR branch di-loading with baseline commit 2e98fc4 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-commenter commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 79.24528% with 11 lines in your changes missing coverage. Please review.

Project coverage is 97.73%. Comparing base (2e98fc4) to head (a482c0f).

Files with missing lines Patch % Lines
lib/datadog/di/base.rb 71.42% 8 Missing ⚠️
spec/datadog/di/init_spec.rb 87.50% 2 Missing ⚠️
lib/datadog/di/code_tracker.rb 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4239      +/-   ##
==========================================
- Coverage   97.73%   97.73%   -0.01%     
==========================================
  Files        1352     1354       +2     
  Lines       82424    82449      +25     
  Branches     4232     4236       +4     
==========================================
+ Hits        80558    80581      +23     
- Misses       1866     1868       +2     

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

@ivoanjo
Copy link
Member

ivoanjo commented Jan 6, 2025

While this PR changes the behavior of datadog/di/init, this behavior has not yet been documented anywhere and should not be used by customers.

If I can offer some advice on this, is as much as possible don't expose any API that's expected to be used directly by customers in DI. Specifically, since DI is mostly about "turn it on, then go to the datadog UX to clicky clicky", it's worth taking advantage of this by not allowing too much configuration/fiddling/and manual operations.

This is somewhat similar to profiling: it's supported to be -- turn it on, then go look at the results. There's one or two public APIs but very very little surface, which has made it much easier to move fast and improve things without needing to walk on egg shells (or needing to put extra work or add extra overhead to comply with some specific public APIs)

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Left a few notes!

lib/datadog/di/base.rb Show resolved Hide resolved
lib/datadog/di/base.rb Outdated Show resolved Hide resolved
lib/datadog/di/base.rb Outdated Show resolved Hide resolved
lib/datadog/di/base.rb Show resolved Hide resolved
@ivoanjo ivoanjo added this to the 2.9.0 milestone Jan 6, 2025
@p-datadog p-datadog removed this from the 2.9.0 milestone Jan 8, 2025
p added 4 commits January 8, 2025 23:01
* master:
  DEBUG-3210 DI: change logging to be appropriate for customer inspection (#4266)
  Report timing information if try_wait_until times out (#4265)
  Move simplecov patch to an overlay in our tree instead of using a forked simplecov repo (#4263)
  DEBUG-3251 dependency inject logger into DI component (#4262)
  DEBUG-3182 move Rails utils to core (#4261)
  add supported versions workflow (#4210)
  DEBUG-3305 remove dependency on benchmark (#4259)
  Fix case & grammar in issue template (#4244)
  [🤖] Update Latest Dependency: https://github.com/DataDog/dd-trace-rb/actions/runs/12614773826
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

👍

We spoke via dm and while I'm somewhat concerned about the complexity around tracking the current component (locks, state to be tracked, potential memory leaks if not used correctly), this PR only moves something that already existed, so we can tackle that separately.

@p-datadog p-datadog merged commit bb43112 into master Jan 9, 2025
337 checks passed
@p-datadog p-datadog deleted the di-loading branch January 9, 2025 13:00
@github-actions github-actions bot added this to the 2.9.0 milestone Jan 9, 2025
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