-
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
use SPI to manage components #1412
Open
brettmc
wants to merge
49
commits into
open-telemetry:2.x
Choose a base branch
from
brettmc:composer-extra-registry
base: 2.x
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.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
abd9944
generate registry from composer autoload-dump
brettmc 43ebe82
use SPI to configure registry
brettmc 8e17eaa
fix b3
brettmc d252d31
don't static init registry from SPI. add tests
brettmc d0fb06c
always use SPI
brettmc b157de2
tidy registry
brettmc 98c1ce0
remove phan suppressions
brettmc 663998d
dont define built-in propagators in SPI
brettmc 77b5d7c
update examples
brettmc 9f7d95b
formatting, remove unused factories
brettmc 5ffe83b
tidy
brettmc 95edf15
generate registry from composer autoload-dump
brettmc 8f26132
use SPI to configure registry
brettmc b07b16a
fix b3
brettmc 3481905
don't static init registry from SPI. add tests
brettmc 9475249
always use SPI
brettmc 93829f3
tidy registry
brettmc 0d8662d
remove phan suppressions
brettmc 1744c84
dont define built-in propagators in SPI
brettmc fa1b678
update examples
brettmc af53feb
formatting, remove unused factories
brettmc 0af0b54
tidy
brettmc 37f8176
remove blank lines after class opening (#1468)
brettmc b90344e
adding otlp/file exporter (#1465)
brettmc b4484c4
deprecate event logger (#1466)
brettmc 5a0dc98
use SPI for stdout otlp exporters
brettmc eb256a2
Merge branch '2.x' into composer-extra-registry
brettmc 4cdc497
Merge branch 'composer-extra-registry' of github.com:brettmc/opentele…
brettmc 4e3a60c
fix merge conflict
brettmc b3cd9f3
remove otlphttp transport factory, in favour of psr transport factory
brettmc 0df5bcf
remove registerXXX methods from Registry
brettmc 0708e47
move Registry to common/service/loader
brettmc 4159f2e
Merge branch '2.x' into composer-extra-registry
brettmc 01e7c70
add stdout exporters to SPI, remove otlphttp transport factory from SPI
brettmc 24b72bd
use spi.prune_autoload_files=true where possible
brettmc e33845b
fix composer.json, add upgrading guide
brettmc 7dbe592
simplify resource detector loading
brettmc b506de9
use _register.php to register SPI classes
brettmc 9b96b79
use _register.php to register SPI classes
brettmc ed836e9
tidy up service loader
brettmc 63264fd
simplify services loader code
brettmc 4f24708
register and use API propagators through SPI
brettmc 540243e
Merge branch 'composer-extra-registry' of github.com:brettmc/opentele…
brettmc b7b9ca1
filter out 'none' compression
brettmc ff3299c
update upgrading docs
brettmc b7af73d
move type() and priority() into a shared interface
brettmc a8fc516
factory test coverage
brettmc 3e80235
tests, configure bypass-finals
brettmc 93f25f8
coverage
brettmc 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
deptrac: | ||
skip_violations: | ||
/src/Extension/Propagator/B3/_register.php: | ||
- OpenTelemetry\SDK\Registry | ||
/src/Extension/Propagator/CloudTrace/_register.php: | ||
- OpenTelemetry\SDK\Registry | ||
/src/Extension/Propagator/Jaeger/_register.php: | ||
- OpenTelemetry\SDK\Registry |
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 |
---|---|---|
|
@@ -146,6 +146,7 @@ deptrac: | |
- Prometheus | ||
Extension: | ||
- +API | ||
- SDK | ||
OtelProto: | ||
- GoogleProtobuf | ||
- Grpc |
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,29 @@ | ||
# Upgrading notes for major versions | ||
|
||
## 1.x -> 2.x | ||
|
||
### API | ||
|
||
### SDK | ||
|
||
#### SDK\Registry removed | ||
`SDK\Registry` has been removed, and the technique of registering components (eg propagators, transports, | ||
auto-instrumentations) has been replaced with [Nevay/SPI](https://github.com/Nevay/spi/) ServiceLoader. | ||
|
||
The ServiceLoader should be configured through existing `_register.php` files, which should *only* contain calls to | ||
SPI's `ServiceLoader::register()` method. | ||
|
||
SPI has a composer plugin which will scan for `ServiceLoader::register()` calls in `autoload.files` and generate a | ||
`GeneratedServiceProviderData.php` file in `vendor/composer/`. The plugin will then remove those `autoload.files` entries | ||
from composer's generated output to avoid double-loading. | ||
Pre-generating the services in this way avoids a race-condition in 1.x where composer's `autoload.files` are executed in an | ||
undefined order, and services may not be registered in time for the SDK to use them. | ||
|
||
For SPI to work correctly, the composer plugin _should_ be allowed to run. If the plugin is not allowed to run, then | ||
services will still register at runtime, however this might still suffer from the same race-condition as `1.x`. | ||
|
||
#### FactoryInterfaces updated | ||
Various component factory interfaces (eg `TextMapPropagatorFactoryInterface`, `TransportFactoryInterface`) have been | ||
updated to include `priority()` and `type()` methods. These are used in conjunction with SPI ServiceLoader to associate | ||
a type (eg `otlp`) with a factory, and to allow SDK-provided factories to be replaced by user-provided factories (by | ||
providing a higher priority for the same type). |
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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Example; | ||
|
||
use OpenTelemetry\SDK\Common\Attribute\Attributes; | ||
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface; | ||
use OpenTelemetry\SDK\Resource\ResourceInfo; | ||
use OpenTelemetry\SemConv\ResourceAttributes; | ||
|
||
class TestResourceDetector implements ResourceDetectorInterface | ||
{ | ||
public function getResource(): ResourceInfo | ||
{ | ||
$attributes = [ | ||
'test-resource' => 'test-value', | ||
]; | ||
|
||
return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Example; | ||
|
||
use OpenTelemetry\SDK\Resource\ResourceDetectorFactoryInterface; | ||
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface; | ||
|
||
class TestResourceDetectorFactory implements ResourceDetectorFactoryInterface | ||
{ | ||
public function create(): ResourceDetectorInterface | ||
{ | ||
return new TestResourceDetector(); | ||
} | ||
|
||
public function type(): string | ||
{ | ||
return 'test'; | ||
} | ||
|
||
public function priority(): int | ||
{ | ||
return 0; | ||
} | ||
} |
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
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
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.
Could use
extra.spi-config.autoload-files
and remove theextra.spi
entries to load the service providers from_register.php
s.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 moved most of these to an appropriate
_register.php
, excepting some test instances and the API's ExtensionHookManager...