Skip to content

Commit e34f242

Browse files
authored
Fixing build failures (#85)
* fixing aws for 0.0.16 update to use ContextInterface and SpanContextValidator * don't fail fast on build errors
1 parent f0e6db3 commit e34f242

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ on:
99

1010
jobs:
1111
php:
12-
1312
runs-on: ubuntu-latest
13+
continue-on-error: true
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
operating-system: [ubuntu-latest]
1718
php-version: ['7.4', '8.0', '8.1']

src/Aws/src/Xray/Propagator.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use OpenTelemetry\API\Trace as API;
2323
use OpenTelemetry\API\Trace\SpanContext;
2424
use OpenTelemetry\Context\Context;
25+
use OpenTelemetry\Context\ContextInterface;
2526
use OpenTelemetry\Context\Propagation\ArrayAccessGetterSetter;
2627
use OpenTelemetry\Context\Propagation\PropagationGetterInterface;
2728
use OpenTelemetry\Context\Propagation\PropagationSetterInterface;
@@ -72,7 +73,7 @@ public function fields(): array
7273
* X-Amzn-Trace-Id: Root={traceId};Parent={parentId};Sampled={samplingFlag}
7374
* X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1
7475
*/
75-
public function inject(&$carrier, PropagationSetterInterface $setter = null, Context $context = null): void
76+
public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
7677
{
7778
$setter = $setter ?? ArrayAccessGetterSetter::getInstance();
7879
$context = $context ?? Context::getCurrent();
@@ -101,7 +102,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con
101102
* This function will parse all parts of the header and validate that it is
102103
* formatted properly to AWS X-ray standards
103104
*/
104-
public function extract($carrier, PropagationGetterInterface $getter = null, Context $context = null): Context
105+
public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
105106
{
106107
$getter = $getter ?? ArrayAccessGetterSetter::getInstance();
107108
$context = $context ?? Context::getCurrent();
@@ -114,8 +115,8 @@ public function extract($carrier, PropagationGetterInterface $getter = null, Con
114115
}
115116

116117
$headerComponents = explode(self::TRACE_HEADER_DELIMITER, $traceHeader);
117-
$parsedTraceId = SpanContext::INVALID_TRACE;
118-
$parsedSpanId = SpanContext::INVALID_SPAN;
118+
$parsedTraceId = API\SpanContextValidator::INVALID_TRACE;
119+
$parsedSpanId = API\SpanContextValidator::INVALID_SPAN;
119120
$sampledFlag = '';
120121

121122
foreach ($headerComponents as $component) {
@@ -157,9 +158,9 @@ public function extract($carrier, PropagationGetterInterface $getter = null, Con
157158
*/
158159
private function parseTraceId($traceId): string
159160
{
160-
$parsedTraceId = SpanContext::INVALID_TRACE;
161+
$parsedTraceId = API\SpanContextValidator::INVALID_TRACE;
161162
$traceIdParts = explode(self::TRACE_ID_DELIMITER, $traceId);
162-
if (count($traceIdParts) > 1 && SpanContext::isValidTraceId($traceIdParts[self::TIMESTAMP_INDEX] .
163+
if (count($traceIdParts) > 1 && API\SpanContextValidator::isValidTraceId($traceIdParts[self::TIMESTAMP_INDEX] .
163164
$traceIdParts[self::RANDOM_HEX_INDEX]) && $traceIdParts[self::VERSION_NUMBER_INDEX] === self::VERSION_NUMBER) {
164165
$parsedTraceId = $traceIdParts[self::TIMESTAMP_INDEX] . $traceIdParts[self::RANDOM_HEX_INDEX];
165166
}

src/Aws/tests/Unit/Xray/IdGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OpenTelemetry\Tests\Aws\Unit\Xray;
66

7-
use OpenTelemetry\API\Trace\SpanContext;
7+
use OpenTelemetry\API\Trace\SpanContextValidator;
88
use OpenTelemetry\Aws\Xray\IdGenerator;
99
use PHPUnit\Framework\TestCase;
1010

@@ -13,7 +13,7 @@ class IdGeneratorTest extends TestCase
1313
public function testGeneratedTraceIdIsValid()
1414
{
1515
$this->assertTrue(
16-
SpanContext::isValidTraceId(
16+
SpanContextValidator::isValidTraceId(
1717
(new IdGenerator())->generateTraceId()
1818
)
1919
);
@@ -44,7 +44,7 @@ public function testGeneratedTraceIdTimeStampIsCurrent()
4444
public function testGeneratedSpanIdIsValid()
4545
{
4646
$this->assertTrue(
47-
SpanContext::isValidSpanId(
47+
SpanContextValidator::isValidSpanId(
4848
(new IdGenerator())->generateSpanId()
4949
)
5050
);

src/Aws/tests/Unit/Xray/PropagatorTest.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
use OpenTelemetry\API\Trace\SpanContext;
88
use OpenTelemetry\API\Trace\SpanContextInterface;
9+
use OpenTelemetry\API\Trace\SpanContextValidator;
910
use OpenTelemetry\API\Trace\TraceState;
1011
use OpenTelemetry\Aws\Xray\Propagator;
1112
use OpenTelemetry\Context\Context;
13+
use OpenTelemetry\Context\ContextInterface;
1214
use OpenTelemetry\SDK\Trace\Span;
1315
use PHPUnit\Framework\TestCase;
1416

@@ -109,7 +111,7 @@ public function InjectTraceIdWithInvalidSpanContext()
109111
$carrier,
110112
null,
111113
$this->withSpanContext(
112-
SpanContext::create(SpanContext::INVALID_TRACE, SpanContext::INVALID_SPAN, SpanContextInterface::TRACE_FLAG_SAMPLED, new TraceState('vendor1=opaqueValue1')),
114+
SpanContext::create(SpanContextValidator::INVALID_TRACE, SpanContextValidator::INVALID_SPAN, SpanContextInterface::TRACE_FLAG_SAMPLED, new TraceState('vendor1=opaqueValue1')),
113115
Context::getCurrent()
114116
)
115117
);
@@ -166,8 +168,8 @@ public function ExtractInvalidTraceIdDelimiter()
166168
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
167169
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
168170

169-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
170-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
171+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
172+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
171173
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
172174
$this->assertFalse($context->isRemote());
173175
}
@@ -183,8 +185,8 @@ public function ExtractEmptySpanContext()
183185
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
184186
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
185187

186-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
187-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
188+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
189+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
188190
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
189191
$this->assertFalse($context->isRemote());
190192
}
@@ -201,8 +203,8 @@ public function ExtractInvalidSpanContext()
201203
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
202204
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
203205

204-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
205-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
206+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
207+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
206208
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
207209
$this->assertFalse($context->isRemote());
208210
}
@@ -219,8 +221,8 @@ public function ExtractInvalidTraceId()
219221
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
220222
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
221223

222-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
223-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
224+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
225+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
224226
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
225227
$this->assertFalse($context->isRemote());
226228
}
@@ -236,8 +238,8 @@ public function ExtractInvalidTraceIdLength()
236238
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
237239
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
238240

239-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
240-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
241+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
242+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
241243
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
242244
$this->assertFalse($context->isRemote());
243245
}
@@ -253,8 +255,8 @@ public function ExtractInvalidSpanId()
253255
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
254256
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
255257

256-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
257-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
258+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
259+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
258260
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
259261
$this->assertFalse($context->isRemote());
260262
}
@@ -270,8 +272,8 @@ public function ExtractInvalidSpanIdLength()
270272
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
271273
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
272274

273-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
274-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
275+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
276+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
275277
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
276278
$this->assertFalse($context->isRemote());
277279
}
@@ -287,8 +289,8 @@ public function ExtractNullSampledValue()
287289
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
288290
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
289291

290-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
291-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
292+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
293+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
292294
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
293295
$this->assertFalse($context->isRemote());
294296
}
@@ -304,8 +306,8 @@ public function ExtractInvalidSampleValue()
304306
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
305307
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
306308

307-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
308-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
309+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
310+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
309311
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
310312
$this->assertFalse($context->isRemote());
311313
}
@@ -321,13 +323,13 @@ public function ExtractInvalidXrayVersion()
321323
$carrier = [Propagator::AWSXRAY_TRACE_ID_HEADER => $traceHeader];
322324
$context = Span::fromContext((new Propagator())->extract($carrier))->getContext();
323325

324-
$this->assertSame(SpanContext::INVALID_TRACE, $context->getTraceId());
325-
$this->assertSame(SpanContext::INVALID_SPAN, $context->getSpanId());
326+
$this->assertSame(SpanContextValidator::INVALID_TRACE, $context->getTraceId());
327+
$this->assertSame(SpanContextValidator::INVALID_SPAN, $context->getSpanId());
326328
$this->assertSame(self::NOT_SAMPLED, ($context->isSampled() ? '1' : '0'));
327329
$this->assertFalse($context->isRemote());
328330
}
329331

330-
private function withSpanContext(SpanContextInterface $spanContext, Context $context): Context
332+
private function withSpanContext(SpanContextInterface $spanContext, ContextInterface $context): ContextInterface
331333
{
332334
return $context->withContextValue(Span::wrap($spanContext));
333335
}

0 commit comments

Comments
 (0)