-
Notifications
You must be signed in to change notification settings - Fork 394
Instrument gems that are required after Datadog.configure
#3113
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
Draft
marcotc
wants to merge
26
commits into
master
Choose a base branch
from
auto-patch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8ceb95f
wip
marcotc 816b1a4
wip
marcotc 55db578
wip
marcotc 1e31891
Add Kernel patcher
marcotc 85ebe3a
Integrate with contrib
marcotc ca64577
Rubocop fixes
marcotc 31382bf
Move scratch code outside of lib
marcotc 709ecb3
Restore scratch file
marcotc 5314fc9
wip
marcotc 9ed3a62
wip
marcotc 19f48d7
wip
marcotc 8447e42
wip
marcotc f72644c
wip
marcotc f167be1
wip
marcotc fb14a10
wip
marcotc 577a7c5
wip
marcotc 1684f44
wip
marcotc f1791c8
Update gemfiles/*
marcotc 96e55ba
Merge branch 'master' into auto-patch
marcotc 1fe4afe
Better docs
marcotc c7ac49d
Merge branch 'master' into auto-patch
marcotc 491c09e
wip
marcotc 607841a
wip
marcotc 4f62d4d
wip
marcotc bfd4262
wip
marcotc c46ea29
wip
marcotc 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 hidden or 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 hidden or 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 +1,4 @@ | ||
eval_gemfile("#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION.split('.').take(2).join('.')}.gemfile") | ||
|
||
gem 'faraday' | ||
# gem 'rails', '4.0.13' |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# rubocop:disable | ||
require 'datadog' | ||
|
||
# module Datadog | ||
# module Tracing | ||
# module Contrib | ||
# module Kernel | ||
# def require(name) | ||
# just_loaded = super | ||
# | ||
# @@dd_instance.require(name) if just_loaded | ||
# | ||
# just_loaded | ||
# end | ||
# | ||
# class Instance | ||
# def initialize | ||
# @on_require = {} | ||
# end | ||
# | ||
# def require(name) | ||
# if @on_require.include?(name) | ||
# Datadog.logger.debug { "Gem '#{name}' loaded. Invoking callback." } | ||
# | ||
# @on_require[name].call | ||
# end | ||
# rescue => e | ||
# Datadog.logger.debug do | ||
# "Failed to execute callback for gem '#{name}': #{e.class.name} #{e.message} at #{Array(e.backtrace).join("\n")}" | ||
# end | ||
# end | ||
# | ||
# def on_require(gem, &block) | ||
# @on_require[gem] = block | ||
# end | ||
# end | ||
# | ||
# @@dd_instance = Instance.new | ||
# | ||
# def self.on_require(gem, &block) | ||
# @@dd_instance.on_require(gem, &block) | ||
# end | ||
# | ||
# def self.patch! | ||
# ::Kernel.prepend(self) | ||
# end | ||
# | ||
# DD_PATCH_ONLY_ONCE = Datadog::Core::Utils::OnlyOnce.new | ||
# private_constant :DD_PATCH_ONLY_ONCE | ||
# end | ||
# end | ||
# end | ||
# end | ||
# | ||
# Datadog::Tracing::Contrib::Kernel.patch! # TODO: I think this stays here actually! | ||
|
||
ENV['DD_TRACE_DEBUG'] = 'true' | ||
|
||
# Setup | ||
require 'datadog' | ||
|
||
Datadog.configure do |c| | ||
c.tracing.instrument :faraday | ||
end | ||
|
||
require 'faraday' | ||
|
||
# User application | ||
Faraday.get('http://example.com') | ||
|
||
# Tear down | ||
Datadog.shutdown! # Ensure traces have been flushed | ||
|
||
# rubocop:enable |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
🔵 Code Vulnerability
Do not use cleartext protocol http:// (...read more)
This rule is designed to prevent the use of the insecure HTTP protocol in your Ruby code. The HTTP protocol does not encrypt the data that is sent between the client and the server, which can lead to sensitive information being intercepted by malicious parties. This is particularly risky when dealing with sensitive data such as API keys, user credentials, or personal user information.
The importance of this rule lies in the security and integrity of your application. By using an unsecured protocol like HTTP, you expose your application and its users to potential data breaches. A breach can lead to loss of trust, legal liability, and significant remediation costs.
To avoid violating this rule, always use the HTTPS protocol when making network requests. HTTPS encrypts the data sent between the client and server, protecting it from interception. By using libraries like
Faraday
,HTTPX
,HTTParty
,RestClient
, or Ruby's built-inNet::HTTP
, you can specify HTTPS by simply replacing 'http://' with 'https://'. For example, instead ofHTTP.get("http://example.org")
, useHTTP.get("https://example.org")
. Always ensure that any third-party services your application interacts with support HTTPS.