-
Notifications
You must be signed in to change notification settings - Fork 375
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
Refactor:Move distributed propagation to Contrib #2352
Merged
Merged
Changes from 15 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
76dfe37
Merge branch 'master' into refactor-propagation-2
marcotc 135e58e
Avoid duplication in distributed tracing strategies
marcotc b621972
Merge branch 'feat-Sampling-Propagation' into refactor-propagation-2
marcotc 243050e
Merge branch 'feat-Sampling-Propagation' into refactor-propagation-2
marcotc 0166025
Simplity test constants
marcotc af7c159
GRPC fixes
marcotc a5c5513
Expand comment
marcotc 7f9e59e
Merge branch 'master' into refactor-propagation-2
marcotc 6d2d00f
Move core distributed to tracing
marcotc c918273
Clean up language around headers
marcotc fe38b24
Remove comment
marcotc 72bc3a6
Freeze string literals
marcotc f8ecf3a
Add String refinement for unary plus
marcotc f05e27c
Simplify test
marcotc 6eecfbc
Sorbet
marcotc 13ef267
Add comment on public api method not raising error
marcotc cedfe2b
Use duck typying
marcotc 5650505
Remove misleading comment about nil returns
marcotc 8f86955
Document mismatched context extraction
marcotc 2830b3a
Move debug log to block
marcotc e261e8e
Remove one-line classes
marcotc 62fcea8
Make fetcher mandatory
marcotc 17bfa34
Update lib/datadog/tracing/distributed/b3_single.rb
marcotc c81fd81
Update lib/datadog/tracing/distributed/datadog.rb
marcotc e877d99
Add _key to propagation key names
marcotc 998ffb3
Sacrifice for the linting gods ☠️
marcotc 70dd590
Use keyword argument for base
marcotc 1374774
Fix log message tests
marcotc 076a784
Apply suggestion
marcotc 7c394e0
Copy dev comment
marcotc 6462cf8
Example constant comment
marcotc b4c8239
B3 single header test shared variable
marcotc 52da1c1
Update spec/datadog/tracing/distributed/fetcher_spec.rb
marcotc bb60a3a
Update last b3 key
marcotc df12297
Remove unused files after refactor
marcotc 98bf97f
Add return value to inject!
marcotc 998f35b
Revert mistakenly moved metadata file
marcotc 61c3b9a
Revert mistakenly moved metadata file
marcotc bb08ca8
Remove unused rquire
marcotc 5efac8a
Remove unused require
marcotc 35dddbc
Consolidate fetcher and helper tests
marcotc b39ce1c
Refactor lib/datadog/tracing/distributed/datadog.rb
marcotc 658f497
Rubocop
marcotc 1bbeb5e
Simplify rack header logic
marcotc bf39755
Revert refinement changes
marcotc 6c69871
Make ext headers its own copy
marcotc 0975630
Move constants closer to ownership
marcotc 23f75b5
Fix typo
marcotc 11d3103
Update lib/datadog/tracing/distributed/datadog.rb
marcotc ebf82b8
Update lib/datadog/tracing/distributed/propagation.rb
marcotc 51ea9f4
Inline x-datadog-origin in tests
marcotc 8af6f31
Add test to protect to_i
marcotc 2150c88
Fix ext migration
marcotc 129d823
Disable sorbet due to *args
marcotc 9df6d9d
Fix no style injection test
marcotc 573eaf1
Change description on to_i invalid format
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 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,38 @@ | ||
# frozen_string_literal: true | ||
# typed: false | ||
|
||
module Datadog | ||
module Core | ||
module Utils | ||
# A collection of refinements for core Ruby features. | ||
# Backports future features to old rubies. | ||
module Refinement | ||
# rubocop:disable Style/Documentation | ||
module Regexp | ||
refine ::Regexp do | ||
# `Regexp::match?` is measurably the most performant | ||
# way to check if a String matches a regular expression. | ||
# | ||
# Introduced in Ruby 2.4. | ||
def match?(*args) | ||
!match(*args).nil? | ||
end | ||
end | ||
end | ||
|
||
module String | ||
refine ::String do | ||
# When not sure if a String is mutable and but it's necessary to perform | ||
# changes to it, `+@` is measurable faster than a possibly unnecessary `.dup`. | ||
# | ||
# Introduced in Ruby 2.3. | ||
def +@ | ||
frozen? ? dup : self | ||
end | ||
end | ||
end | ||
# rubocop:enable Style/Documentation | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/b3' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module GRPC | ||
module Distributed | ||
# B3-style trace propagation through gRPC metadata. | ||
# @see https://github.com/openzipkin/b3-propagation#multiple-headers | ||
# @see https://github.com/grpc/grpc-go/blob/v1.50.1/Documentation/grpc-metadata.md gRPC metadata | ||
class B3 < Tracing::Distributed::B3 | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/b3_single' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module GRPC | ||
module Distributed | ||
# B3 single header-style trace propagation through gRPC metadata. | ||
# @see https://github.com/openzipkin/b3-propagation#single-header | ||
# @see https://github.com/grpc/grpc-go/blob/v1.50.1/Documentation/grpc-metadata.md gRPC metadata | ||
class B3Single < Tracing::Distributed::B3Single | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/datadog' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module GRPC | ||
module Distributed | ||
# Datadog-style trace propagation through gRPC metadata. | ||
# @see https://github.com/grpc/grpc-go/blob/v1.50.1/Documentation/grpc-metadata.md gRPC metadata | ||
class Datadog < Tracing::Distributed::Datadog | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module GRPC | ||
module Distributed | ||
# Retrieves values from the gRPC metadata. | ||
class Fetcher < Tracing::Distributed::Fetcher | ||
def [](key) | ||
# Metadata values can be arrays (multiple values for the same key) | ||
value = super(key) | ||
value.is_a?(::Array) ? value[0] : value | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
lib/datadog/tracing/contrib/grpc/distributed/propagation.rb
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/propagation' | ||
require_relative 'b3' | ||
require_relative 'b3_single' | ||
require_relative 'datadog' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module GRPC | ||
module Distributed | ||
# Extracts and injects propagation through gRPC metadata. | ||
class Propagation < Tracing::Distributed::Propagation | ||
def initialize | ||
super( | ||
propagation_styles: { | ||
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3 => B3.new, | ||
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER => B3Single.new, | ||
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG => Datadog.new, | ||
}) | ||
end | ||
|
||
# DEV: Singleton kept until a larger refactor is performed. | ||
# DEV: See {Datadog::Tracing::Distributed::Propagation#initialize} for more information. | ||
INSTANCE = Propagation.new | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/b3' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module HTTP | ||
module Distributed | ||
# B3-style trace propagation through HTTP headers. | ||
# @see https://github.com/openzipkin/b3-propagation#multiple-headers | ||
class B3 < Tracing::Distributed::B3 | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
marcotc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/b3_single' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module HTTP | ||
module Distributed | ||
# B3 single header-style trace propagation through HTTP headers. | ||
# @see https://github.com/openzipkin/b3-propagation#single-header | ||
class B3Single < Tracing::Distributed::B3Single | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
# typed: true | ||
|
||
require_relative '../../../distributed/datadog' | ||
require_relative 'fetcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module HTTP | ||
module Distributed | ||
# Datadog-style trace propagation through HTTP headers. | ||
class Datadog < Tracing::Distributed::Datadog | ||
def initialize | ||
super(fetcher: Fetcher) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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.
These were just unnecessary and actually the responsibility of
intercept_with_datadog.rb
.