Skip to content
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

Prevent propagator packages from throwing fatal error if sdk not installed #1198

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions deptrac.baseline.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
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
30 changes: 14 additions & 16 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,32 @@ deptrac:
layers:
- name: API
collectors:
- type: className
regex: ^OpenTelemetry\\API\\*
- type: directory
value: src/API/.*
- name: SDK
collectors:
- type: className
regex: ^OpenTelemetry\\SDK\\*
- type: directory
value: src/SDK/.*
- name: Context
collectors:
- type: className
regex: ^OpenTelemetry\\Context\\*
- type: directory
value: src/Context/.*
- name: SemConv
collectors:
- type: className
regex: ^OpenTelemetry\\SemConv\\*
- type: directory
value: src/SemConv/.*
- name: Contrib
collectors:
- type: className
regex: ^OpenTelemetry\\Contrib\\*
- type: directory
value: src/Contrib/.*
- name: Extension
collectors:
- type: className
regex: ^OpenTelemetry\\Extension\\*
- type: directory
value: src/Extension/.*
- name: OtelProto
collectors:
- type: className
regex: ^OpenTelemetry\\Proto\\*
- type: className
regex: ^GPBMetadata\\Opentelemetry\\*
- type: directory
value: proto/otel/.*
- name: GoogleProtobuf
collectors:
- type: className
Expand Down
9 changes: 6 additions & 3 deletions src/Extension/Propagator/B3/_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
declare(strict_types=1);

use OpenTelemetry\Extension\Propagator\B3\B3Propagator;
use OpenTelemetry\SDK\Common\Configuration\KnownValues;
use OpenTelemetry\SDK\Registry;

if (!class_exists(Registry::class)) {
return;
}

Registry::registerTextMapPropagator(
KnownValues::VALUE_B3,
'b3',
B3Propagator::getB3SingleHeaderInstance()
);
Registry::registerTextMapPropagator(
KnownValues::VALUE_B3_MULTI,
'b3multi',
B3Propagator::getB3MultiHeaderInstance()
);
9 changes: 6 additions & 3 deletions src/Extension/Propagator/CloudTrace/_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
declare(strict_types=1);

use OpenTelemetry\Extension\Propagator\CloudTrace\CloudTracePropagator;
use OpenTelemetry\SDK\Common\Configuration\KnownValues;
use OpenTelemetry\SDK\Registry;

if (!class_exists(Registry::class)) {
return;
}

Registry::registerTextMapPropagator(
KnownValues::VALUE_CLOUD_TRACE,
'cloudtrace',
CloudTracePropagator::getInstance()
);

Registry::registerTextMapPropagator(
KnownValues::VALUE_CLOUD_TRACE_ONEWAY,
'cloudtrace-oneway',
CloudTracePropagator::getOneWayInstance()
);
9 changes: 6 additions & 3 deletions src/Extension/Propagator/Jaeger/_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

use OpenTelemetry\Extension\Propagator\Jaeger\JaegerBaggagePropagator;
use OpenTelemetry\Extension\Propagator\Jaeger\JaegerPropagator;
use OpenTelemetry\SDK\Common\Configuration\KnownValues;
use OpenTelemetry\SDK\Registry;

if (!class_exists(Registry::class)) {
return;
}

Registry::registerTextMapPropagator(
KnownValues::VALUE_JAEGER,
'jaeger',
JaegerPropagator::getInstance()
);

Registry::registerTextMapPropagator(
KnownValues::VALUE_JAEGER_BAGGAGE,
'jaeger-baggage',
JaegerBaggagePropagator::getInstance()
);
Loading