File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
src/Instrumentation/Laravel/src Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace OpenTelemetry \Contrib \Instrumentation \Laravel ;
6+
7+ use OpenTelemetry \API \Instrumentation \AutoInstrumentation \InstrumentationConfiguration ;
8+ use OpenTelemetry \Config \SDK \Configuration \ComponentProvider ;
9+ use OpenTelemetry \Config \SDK \Configuration \ComponentProviderRegistry ;
10+ use OpenTelemetry \Config \SDK \Configuration \Context ;
11+ use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
12+
13+ class LaravelComponentProvider implements ComponentProvider
14+ {
15+ public function createPlugin (array $ properties , Context $ context ): InstrumentationConfiguration
16+ {
17+ return LaravelConfiguration::fromArray ($ properties );
18+ }
19+
20+ public function getConfig (ComponentProviderRegistry $ registry ): ArrayNodeDefinition
21+ {
22+ $ root = new ArrayNodeDefinition ('laravel ' );
23+
24+ return $ root
25+ ->canBeDisabled ()
26+ ->addDefaultsIfNotSet ()
27+ ;
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace OpenTelemetry \Contrib \Instrumentation \Laravel ;
6+
7+ use OpenTelemetry \API \Instrumentation \AutoInstrumentation \InstrumentationConfiguration ;
8+ use OpenTelemetry \SDK \Sdk ;
9+
10+ final class LaravelConfiguration implements InstrumentationConfiguration
11+ {
12+ private function __construct (
13+ public readonly bool $ enabled ,
14+ ) {
15+ }
16+
17+ public static function fromArray (array $ properties ): self
18+ {
19+ return new self (
20+ enabled: $ properties ['enabled ' ] ?? (class_exists (Sdk::class) ? !Sdk::isDisabled () : true ),
21+ );
22+ }
23+
24+ public static function default (): self
25+ {
26+ return self ::fromArray ([]);
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments