11<?php 
2+ 
3+ declare (strict_types=1 );
24// src/Sampler/AWS/AWSXRayRemoteSampler.php 
35
46namespace  OpenTelemetry \Contrib \Sampler \Xray ;
57
68use  DateTimeImmutable ;
79use  Exception ;
8- use  OpenTelemetry \SDK \Trace \Sampler \ParentBased ;
910use  OpenTelemetry \Context \ContextInterface ;
1011use  OpenTelemetry \SDK \Common \Attribute \AttributesInterface ;
11- use  OpenTelemetry \SDK \Trace \SamplerInterface ;
1212use  OpenTelemetry \SDK \Resource \ResourceInfo ;
13+ use  OpenTelemetry \SDK \Trace \Sampler \ParentBased ;
14+ use  OpenTelemetry \SDK \Trace \SamplerInterface ;
1315use  OpenTelemetry \SDK \Trace \SamplingResult ;
1416
15- 
16- class  AWSXRayRemoteSampler  implements  SamplerInterface  {
17+ class  AWSXRayRemoteSampler  implements  SamplerInterface 
18+ {
1719    private  SamplerInterface $ root
1820    public  function  __construct (
1921        ResourceInfo $ resource
20-         string         $ host
21-         int            $ rulePollingIntervalMillis60 
22+         string  $ host
23+         int  $ rulePollingIntervalMillis60 
2224    ) {
2325        $ this root  = new  ParentBased (new  _AWSXRayRemoteSampler ($ resource$ host$ rulePollingIntervalMillis
2426    }
@@ -30,8 +32,7 @@ public function shouldSample(
3032        int  $ spanKind
3133        AttributesInterface $ attributes
3234        array  $ links
33-     ): SamplingResult 
34-     {
35+     ): SamplingResult 
3536        return  $ this root ->shouldSample ($ parentContext$ traceId$ spanName$ spanKind$ attributes$ links
3637    }
3738
@@ -76,8 +77,8 @@ class _AWSXRayRemoteSampler implements SamplerInterface
7677     */ 
7778    public  function  __construct (
7879        ResourceInfo $ resource
79-         string         $ awsProxyEndpointself ::DEFAULT_AWS_PROXY_ENDPOINT ,
80-         int            $ pollingIntervalself ::DEFAULT_RULES_POLLING_INTERVAL_SECONDS 
80+         string  $ awsProxyEndpointself ::DEFAULT_AWS_PROXY_ENDPOINT ,
81+         int  $ pollingIntervalself ::DEFAULT_RULES_POLLING_INTERVAL_SECONDS 
8182    ) {
8283        $ this clock                    = new  Clock ();
8384        $ this fallback                 = new  FallbackSampler ();
@@ -108,8 +109,8 @@ public function __construct(
108109
109110        // 2) Schedule next fetch times with jitter 
110111        $ now$ this clock ->now ();
111-         $ this nextRulesFetchTime       = $ nowmodify ('+  ' . $ this rulePollingJitterMillis  + $ this rulePollingIntervalMillis . ' milliseconds ' );
112-         $ this nextTargetFetchTime      = $ nowmodify ('+  ' . $ this targetPollingJitterMillis  + $ this targetPollingIntervalMillis . ' milliseconds ' );
112+         $ this nextRulesFetchTime       = $ nowmodify ('+  '  .  $ this rulePollingJitterMillis  + $ this rulePollingIntervalMillis  .  ' milliseconds ' );
113+         $ this nextTargetFetchTime      = $ nowmodify ('+  '  .  $ this targetPollingJitterMillis  + $ this targetPollingIntervalMillis  .  ' milliseconds ' );
113114    }
114115
115116    /** 
@@ -122,8 +123,7 @@ public function shouldSample(
122123        int  $ spanKind
123124        AttributesInterface $ attributes
124125        array  $ links
125-     ): SamplingResult 
126-     {
126+     ): SamplingResult 
127127        $ now$ this clock ->now ();
128128
129129        // 1) Refresh rules if needed 
@@ -166,7 +166,7 @@ public function shouldSample(
166166
167167            $ nextTargetFetchInterval$ nextTargetFetchInterval1000 ;
168168
169-             $ this nextTargetFetchTime  = $ nowmodify ('+  ' . $ this targetPollingJitterMillis  + $ nextTargetFetchInterval. ' milliseconds ' );
169+             $ this nextTargetFetchTime  = $ nowmodify ('+  '  .  $ this targetPollingJitterMillis  + $ nextTargetFetchInterval .  ' milliseconds ' );
170170
171171        }
172172
@@ -175,6 +175,7 @@ public function shouldSample(
175175        if  ($ this rulesCache ->expired ()) {
176176            return  $ this fallback ->shouldSample ($ parentContext$ traceId$ spanName$ spanKind$ attributes$ links
177177        }
178+ 
178179        // delegate 
179180        return  $ this rulesCache ->shouldSample ($ parentContext$ traceId$ spanName$ spanKind$ attributes$ links
180181    }
@@ -187,7 +188,7 @@ private function getAndUpdateRules(DateTimeImmutable $now)
187188        } catch  (Exception $ e
188189            // ignore error 
189190        }
190-         $ this nextRulesFetchTime  = $ nowmodify ('+  ' . $ this rulePollingJitterMillis  + $ this rulePollingIntervalMillis . ' milliseconds ' );
191+         $ this nextRulesFetchTime  = $ nowmodify ('+  '  .  $ this rulePollingJitterMillis  + $ this rulePollingIntervalMillis  .  ' milliseconds ' );
191192    }
192193
193194    public  function  getDescription (): string 
0 commit comments