Skip to content

Commit 038731f

Browse files
committed
updated more files
1 parent f9174d2 commit 038731f

12 files changed

+15
-31
lines changed

src/Sampler/Xray/psalm.xml.dist

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<psalm
33
errorLevel="3"
44
cacheDirectory="var/cache/psalm"
5-
findUnusedBaselineEntry="false"
6-
findUnusedCode="false"
75
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
86
xmlns="https://getpsalm.org/schema/config"
97
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
@@ -14,16 +12,4 @@
1412
<plugins>
1513
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
1614
</plugins>
17-
<issueHandlers>
18-
<UndefinedInterfaceMethod>
19-
<errorLevel type="suppress">
20-
<directory name="src/ComponentProvider"/>
21-
</errorLevel>
22-
</UndefinedInterfaceMethod>
23-
<MoreSpecificImplementedParamType>
24-
<errorLevel type="suppress">
25-
<directory name="src/ComponentProvider"/>
26-
</errorLevel>
27-
</MoreSpecificImplementedParamType>
28-
</issueHandlers>
2915
</psalm>

src/Sampler/Xray/src/AWSXRaySamplerClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace OpenTelemetry\Contrib\Sampler\Xray;
77

88
use GuzzleHttp\Client as HttpClient;
9-
use GuzzleHttp\Exception\GuzzleException;
109

1110
/**
1211
* A lightweight HTTP client for AWS X-Ray sampling endpoints.
@@ -34,7 +33,6 @@ public function __construct(string $host)
3433
/**
3534
* Fetches all sampling rules from X-Ray by paging through NextToken.
3635
*
37-
* @throws GuzzleException on HTTP errors.
3836
* @return SamplingRule[] Array of SamplingRule instances.
3937
*/
4038
public function getSamplingRules(): array
@@ -70,7 +68,6 @@ public function getSamplingRules(): array
7068
* Sends current statistics documents to X-Ray and returns the decoded response.
7169
*
7270
* @param SamplingStatisticsDocument[] $statistics
73-
* @throws GuzzleException on HTTP errors.
7471
* @return object|null stdClass of the X-Ray GetSamplingTargets response.
7572
*/
7673
public function getSamplingTargets(array $statistics): ?object

src/Sampler/Xray/src/Clock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public function now(): \DateTimeImmutable
1414

1515
public function toUnixMillis(\DateTimeImmutable $dt): float
1616
{
17-
return ($dt->getTimestamp() * 1000) + ($dt->format('v') / 1);
17+
return $dt->getTimestamp() * 1000;
1818
}
1919
}

src/Sampler/Xray/src/Matcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function wildcardMatch(?string $value, string $pattern): bool
5151
/**
5252
* Map OpenTelemetry cloud.platform values to X-Ray service type strings.
5353
*/
54-
public static function getXRayCloudPlatform(?string $platform): string
54+
public static function getXRayCloudPlatform(string $platform): string
5555
{
5656
return self::$xrayCloudPlatform[$platform] ?? '';
5757
}

src/Sampler/Xray/src/SamplingRuleApplier.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ public function __construct(string $clientId, Clock $clock, SamplingRule $rule,
5151
public function matches(AttributesInterface $attributes, ResourceInfo $resource): bool
5252
{
5353
// Extract HTTP path
54-
$httpTarget = $attributes->get(TraceAttributes::HTTP_TARGET) ?? $attributes->get(TraceAttributes::URL_PATH);
55-
$httpUrl = $attributes->get(TraceAttributes::HTTP_URL) ?? $attributes->get(TraceAttributes::URL_FULL);
54+
$httpTarget = $attributes->get(TraceAttributes::HTTP_TARGET) ?? $attributes->get(TraceAttributes::URL_PATH); // @phan-suppress-current-line PhanDeprecatedClassConstant
55+
$httpUrl = $attributes->get(TraceAttributes::HTTP_URL) ?? $attributes->get(TraceAttributes::URL_FULL); // @phan-suppress-current-line PhanDeprecatedClassConstant
5656
if ($httpTarget == null && isset($httpUrl)) {
5757
$httpTarget = parse_url($httpUrl, PHP_URL_PATH);
5858
}
5959

60-
$httpMethod = $attributes->get(TraceAttributes::HTTP_METHOD) ?? $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD);
60+
$httpMethod = $attributes->get(TraceAttributes::HTTP_METHOD) ?? $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD); // @phan-suppress-current-line PhanDeprecatedClassConstant
6161
if ($httpMethod == '_OTHER') {
6262
$httpMethod = $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD_ORIGINAL);
6363
}
64-
$httpHost = $attributes->get(TraceAttributes::HTTP_HOST) ?? $attributes->get(TraceAttributes::SERVER_ADDRESS) ;
64+
$httpHost = $attributes->get(TraceAttributes::HTTP_HOST) ?? $attributes->get(TraceAttributes::SERVER_ADDRESS) ; // @phan-suppress-current-line PhanDeprecatedClassConstant
6565
$serviceName= $resource->getAttributes()->get(TraceAttributes::SERVICE_NAME) ?? '';
66-
$cloudPlat = $resource->getAttributes()->get(TraceAttributes::CLOUD_PLATFORM) ?? null;
66+
$cloudPlat = $resource->getAttributes()->get(TraceAttributes::CLOUD_PLATFORM) ?? '';
6767
$serviceType= Matcher::getXRayCloudPlatform($cloudPlat);
6868

6969
// ARN: ECS container ARN or Lambda faas.id

src/Sampler/Xray/test/Unit/AWSXraySamplerClientTest.php renamed to src/Sampler/Xray/tests/Unit/AWSXraySamplerClientTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
2+
23
declare(strict_types=1);
34

4-
use PHPUnit\Framework\TestCase;
5-
use OpenTelemetry\Contrib\Sampler\Xray\AWSXRaySamplerClient;
65
use GuzzleHttp\Psr7\Response;
7-
use OpenTelemetry\Contrib\Sampler\Xray\SamplingStatisticsDocument;
6+
use OpenTelemetry\Contrib\Sampler\Xray\AWSXRaySamplerClient;
87
use OpenTelemetry\Contrib\Sampler\Xray\SamplingRule;
8+
use OpenTelemetry\Contrib\Sampler\Xray\SamplingStatisticsDocument;
9+
use PHPUnit\Framework\TestCase;
910

1011
final class AWSXRaySamplerClientTest extends TestCase
1112
{
@@ -92,12 +93,12 @@ public function testGetSamplingTargets(): void
9293

9394
$t1 = $resp->SamplingTargetDocuments[0];
9495
$this->assertSame('test', $t1->RuleName);
95-
$this->assertSame(30, $t1->ReservoirQuota);
96-
$this->assertSame(0.10, $t1->FixedRate);
96+
$this->assertSame(30, $t1->ReservoirQuota);
97+
$this->assertSame(0.10, $t1->FixedRate);
9798

9899
$t2 = $resp->SamplingTargetDocuments[1];
99100
$this->assertSame('Default', $t2->RuleName);
100-
$this->assertSame(0, $t2->ReservoirQuota);
101-
$this->assertSame(0.05, $t2->FixedRate);
101+
$this->assertSame(0, $t2->ReservoirQuota);
102+
$this->assertSame(0.05, $t2->FixedRate);
102103
}
103104
}

0 commit comments

Comments
 (0)