66
77use OpenTelemetry \API \Common \Instrumentation \InstrumentationInterface ;
88use OpenTelemetry \API \Common \Instrumentation \InstrumentationTrait ;
9- use OpenTelemetry \API \Trace \SpanInterface ;
109use OpenTelemetry \API \Trace \SpanKind ;
1110use OpenTelemetry \API \Trace \TracerInterface ;
1211use OpenTelemetry \API \Trace \TracerProviderInterface ;
@@ -24,7 +23,6 @@ class AwsSdkInstrumentation implements InstrumentationInterface
2423 public const SPAN_KIND = SpanKind::KIND_CLIENT ;
2524 private TextMapPropagatorInterface $ propagator ;
2625 private TracerProviderInterface $ tracerProvider ;
27- private SpanInterface $ root ;
2826
2927 public function getName (): string
3028 {
@@ -71,22 +69,11 @@ public function getTracer(): TracerInterface
7169 return $ this ->tracerProvider ->getTracer ('io.opentelemetry.contrib.php ' );
7270 }
7371
74- public function endRootSpan ($ rootScope )
75- {
76- $ rootScope ->detach ();
77- $ this ->root ->end ();
78- }
79-
8072 public function activate (): bool
8173 {
8274 AwsGlobal::setInstrumentation ($ this );
8375
8476 try {
85- $ this ->root = $ this ->getTracer ()->spanBuilder ('AwsSDKInstrumentation ' )->setSpanKind (SpanKind::KIND_CLIENT )->startSpan ();
86- $ rootScope = $ this ->root ->activate ();
87-
88- register_shutdown_function ([$ this , 'endRootSpan ' ], $ rootScope );
89-
9077 runkit7_method_copy ('Aws\AwsClient ' , '__call_copy ' , 'Aws\AwsClient ' , '__call ' );
9178 runkit7_method_copy ('Aws\AwsClient ' , 'executeAsync_copy ' , 'Aws\AwsClient ' , 'executeAsync ' );
9279
@@ -109,6 +96,7 @@ public function activate(): bool
10996 "rpc.method" => $name,
11097 "rpc.service" => $this->getApi()->getServiceName(),
11198 "rpc.system" => "aws-api",
99+ "aws.region" => $this->getRegion()
112100 ]);
113101
114102 return $this->__call_copy($name, $args);
0 commit comments