-
Notifications
You must be signed in to change notification settings - Fork 382
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-2334 Remaining dynamic instrumentation code #4063
Closed
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f7d59a6
DEBUG-2334 Remaining dynamic instrumentation code
p 1ca9523
test local time serialization
p 3d23756
AR serializer tests
p e86694a
put di/utils back
p c930fca
revert worker change
p 8e4495b
do not load DI on ruby 2.5
p 07fefef
fix capabilities test
p bc074e4
mark di tests
p 13f4900
Update lib/datadog/di/probe_manager.rb
p-datadog 389488a
repair di transport
p b4b23b8
rate limiter is now passed
p e8f3674
Merge branch 'master' into di-rest
p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'di/error' | ||
require_relative 'di/configuration' | ||
require_relative 'di/code_tracker' | ||
require_relative 'di/component' | ||
require_relative 'di/configuration' | ||
require_relative 'di/extensions' | ||
require_relative 'di/instrumenter' | ||
require_relative 'di/probe' | ||
require_relative 'di/probe_builder' | ||
require_relative 'di/probe_manager' | ||
require_relative 'di/probe_notification_builder' | ||
require_relative 'di/probe_notifier_worker' | ||
require_relative 'di/redactor' | ||
require_relative 'di/remote' | ||
require_relative 'di/serializer' | ||
require_relative 'di/transport' | ||
require_relative 'di/utils' | ||
|
||
if defined?(ActiveRecord::Base) | ||
# The third-party library integrations need to be loaded after the | ||
# third-party libraries are loaded. Tracing and appsec use Railtie | ||
# to delay integrations until all of the application's dependencies | ||
# are loaded, when running under Rails. We should do the same here in | ||
# principle, however DI currently only has an ActiveRecord integration | ||
# and AR should be loaded before any application code is loaded, being | ||
# part of Rails, therefore for now we should be OK to just require the | ||
# AR integration from here. | ||
require_relative 'di/contrib/active_record' | ||
Comment on lines
+21
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work in a regular Rails app (meaning, |
||
end | ||
|
||
module Datadog | ||
# Namespace for Datadog dynamic instrumentation. | ||
# | ||
# @api private | ||
module DI | ||
class << self | ||
def enabled? | ||
Datadog.configuration.dynamic_instrumentation.enabled | ||
end | ||
end | ||
|
||
# Expose DI to global shared objects | ||
Extensions.activate! | ||
|
||
|
@@ -33,6 +57,8 @@ class << self | |
# existing mappings in the registry | ||
def activate_tracking! | ||
(@code_tracker ||= CodeTracker.new).start | ||
# & is demanded by steep, code tracker is always not nil here. | ||
#code_tracker&.start | ||
end | ||
|
||
# Deactivates code tracking. In normal usage of DI this method should | ||
|
@@ -52,6 +78,28 @@ def deactivate_tracking! | |
def code_tracking_active? | ||
code_tracker&.active? || false | ||
end | ||
|
||
def component | ||
Datadog.send(:components).dynamic_instrumentation | ||
end | ||
end | ||
end | ||
end | ||
|
||
# :script_compiled trace point was added in Ruby 2.6. | ||
if RUBY_VERSION >= '2.6' | ||
begin | ||
# Activate code tracking by default because line trace points will not work | ||
# without it. | ||
Datadog::DI.activate_tracking! | ||
rescue => exc | ||
if defined?(Datadog.logger) | ||
Datadog.logger.warn("Failed to activate code tracking for DI: #{exc.class}: #{exc}") | ||
else | ||
# We do not have Datadog logger potentially because DI code tracker is | ||
# being loaded early in application boot process and the rest of datadog | ||
# wasn't loaded yet. Output to standard error. | ||
warn("Failed to activate code tracking for DI: #{exc.class}: #{exc}") | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it for testing to avoid having to hit the app before it instruments code but it does not belong in this PR, I will revert it.