-
Notifications
You must be signed in to change notification settings - Fork 192
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
create text map propagators from registry #885
Merged
brettmc
merged 3 commits into
open-telemetry:main
from
brettmc:trace-propagators-registry
Dec 9, 2022
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
create text map propagators from registry
removing undocumented dependency between sdk and extension by adding text map propagators to a registry as part of composer autoloading, similar to how exporters, transports etc are treated.
- Loading branch information
commit 0f20a643cb86229bf856c5bf727758d16afcfde9
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\API\Baggage\Propagation; | ||
|
||
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface; | ||
|
||
class BaggagePropagatorFactory implements \OpenTelemetry\Context\Propagation\TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface | ||
{ | ||
return BaggagePropagator::getInstance(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/API/Trace/Propagation/TraceContextPropagatorFactory.php
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\API\Trace\Propagation; | ||
|
||
use OpenTelemetry\Context\Propagation\TextMapPropagatorFactoryInterface; | ||
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface; | ||
|
||
class TraceContextPropagatorFactory implements TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface | ||
{ | ||
return TraceContextPropagator::getInstance(); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Context\Propagation; | ||
|
||
class NoopTextMapPropagatorFactory implements TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface | ||
{ | ||
return NoopTextMapPropagator::getInstance(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Context/Propagation/TextMapPropagatorFactoryInterface.php
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Context\Propagation; | ||
|
||
interface TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface; | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Extension\Propagator\B3; | ||
|
||
use OpenTelemetry\Context\Propagation\TextMapPropagatorFactoryInterface; | ||
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface; | ||
|
||
class B3MultiPropagatorFactory implements TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface | ||
{ | ||
return B3Propagator::getB3MultiHeaderInstance(); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Extension\Propagator\B3; | ||
|
||
use OpenTelemetry\Context\Propagation\TextMapPropagatorFactoryInterface; | ||
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface; | ||
|
||
class B3SinglePropagatorFactory implements TextMapPropagatorFactoryInterface | ||
{ | ||
public function create(): TextMapPropagatorInterface | ||
{ | ||
return B3Propagator::getB3SingleHeaderInstance(); | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
\OpenTelemetry\SDK\FactoryRegistry::registerTextMapPropagatorFactory( | ||
\OpenTelemetry\SDK\Common\Configuration\KnownValues::VALUE_B3, | ||
\OpenTelemetry\Extension\Propagator\B3\B3SinglePropagatorFactory::class | ||
); | ||
\OpenTelemetry\SDK\FactoryRegistry::registerTextMapPropagatorFactory( | ||
\OpenTelemetry\SDK\Common\Configuration\KnownValues::VALUE_B3_MULTI, | ||
\OpenTelemetry\Extension\Propagator\B3\B3MultiPropagatorFactory::class | ||
); |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
\OpenTelemetry\SDK\FactoryRegistry::registerTextMapPropagatorFactory( | ||
\OpenTelemetry\SDK\Common\Configuration\KnownValues::VALUE_BAGGAGE, | ||
\OpenTelemetry\API\Baggage\Propagation\BaggagePropagatorFactory::class | ||
); | ||
\OpenTelemetry\SDK\FactoryRegistry::registerTextMapPropagatorFactory( | ||
\OpenTelemetry\SDK\Common\Configuration\KnownValues::VALUE_TRACECONTEXT, | ||
\OpenTelemetry\API\Trace\Propagation\TraceContextPropagatorFactory::class | ||
); | ||
\OpenTelemetry\SDK\FactoryRegistry::registerTextMapPropagatorFactory( | ||
\OpenTelemetry\SDK\Common\Configuration\KnownValues::VALUE_NONE, | ||
\OpenTelemetry\Context\Propagation\NoopTextMapPropagatorFactory::class | ||
); |
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
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.
I would prefer if we add a
ClosureTextMapPropagatorFactory
(or allow registering closure factories directly) to avoid adding a factory class for every implementation.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've just removed the factories altogether, and registered the propagator instances instead. It's simpler, but also adding non-factories to a
FactoryRegistry
which is a little shady.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.
Agree, that it's simpler, but as you written it breaks rule of storing only factories there. I don't have strong opinions for or against. Maybe, we should consider some renaming as
FactoryRegistry
will no longer store factories only?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've renamed it to
Registry
, which isn't very imaginative but seems valid.