Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getSuppressor(string $name, ?string $version, ?string $schemaUrl
foreach ($semanticConvention->samplingAttributes as $attribute) {
$lookup[$semanticConvention->spanKind][$attribute][0] |= 1 << $i;
}
foreach ($lookup[$semanticConvention->spanKind] as $attribute => $_) {
foreach (array_keys($lookup[$semanticConvention->spanKind]) as $attribute) {
if (!$attributes->matches($attribute)) {
$lookup[$semanticConvention->spanKind][$attribute][1] |= 1 << $i;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SDK/Trace/TracerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
?IdGeneratorInterface $idGenerator = null,
?InstrumentationScopeFactoryInterface $instrumentationScopeFactory = null,
private ?Configurator $configurator = null,
private SpanSuppressionStrategy $spanSuppressionStrategy = new NoopSuppressionStrategy(),
private readonly SpanSuppressionStrategy $spanSuppressionStrategy = new NoopSuppressionStrategy(),
) {
$spanProcessors ??= [];
$spanProcessors = is_array($spanProcessors) ? $spanProcessors : [$spanProcessors];
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Contrib/Otlp/LogsConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function test_convert(): void
$this->record->method('getBody')->willReturn('body');

$request = $this->converter->convert([$this->record]);
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
$row = $request->getResourceLogs()[0]->getScopeLogs()[0]->getLogRecords()[0];
$this->assertSame('body', $row->getBody()->getStringValue());
}
Expand All @@ -49,7 +49,7 @@ public function test_convert_with_context(): void
$span->method('getContext')->willReturn($spanContext);
$this->record->method('getSpanContext')->willReturn($spanContext);
$request = $this->converter->convert([$this->record]);
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
$row = $request->getResourceLogs()[0]->getScopeLogs()[0]->getLogRecords()[0];
$this->assertSame(self::TRACE_ID_BASE16, bin2hex((string) $row->getTraceId()));
$this->assertSame(self::SPAN_ID_BASE16, bin2hex((string) $row->getSpanId()));
Expand Down
14 changes: 8 additions & 6 deletions tests/Unit/Contrib/Otlp/SpanConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class SpanConverterTest extends TestCase
{
/**
* @psalm-suppress InvalidArgument
* @psalm-suppress InvalidArgument,PossiblyNullReference
*/
public function test_convert_span_to_payload(): void
{
Expand Down Expand Up @@ -85,12 +85,13 @@ public function test_span_context_is_remote_flags(): void
$convertSpanData = static function (SpanData $spanData): ProtoSpan {
$converter = new SpanConverter();

/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
return $converter->convert([$spanData])->getResourceSpans()[0]->getScopeSpans()[0]->getSpans()[0];
};

/** @psalm-suppress InvalidNullableReturnType */
$getLink = static function (ProtoSpan $protoSpan, int $linkIndex): ProtoSpanLink {
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,NullableReturnStatement */
return $protoSpan->getLinks()[$linkIndex];
};

Expand Down Expand Up @@ -130,6 +131,7 @@ public function test_attribute_are_coerced_correctly($actual, $expected): void
$converter = new SpanConverter();
/** @psalm-suppress InvalidArgument */
$converted = $converter->convert([$span])->getResourceSpans()[0];
/** @psalm-suppress PossiblyNullReference */
$attributes = $converted->getScopeSpans()[0]->getSpans()[0]->getAttributes();

// Check that we can convert all attributes to tags
Expand Down Expand Up @@ -308,7 +310,7 @@ public function test_resources_from_multiple_spans_are_not_duplicated(): void
$resource->method('getAttributes')->willReturn($attributes);
$converter = new SpanConverter();
$result = $converter->convert([$span, $span, $span])->getResourceSpans();
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
$this->assertCount(2, $result[0]->getResource()->getAttributes());
}

Expand Down Expand Up @@ -339,7 +341,7 @@ public function test_otlp_no_spans(): void
public function test_span_kind($kind, $expected): void
{
$span = (new SpanData())->setKind($kind);
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
$row = (new SpanConverter())->convert([$span])->getResourceSpans()[0]->getScopeSpans()[0]->getSpans()[0];
$this->assertSame($expected, $row->getKind());
}
Expand All @@ -359,7 +361,7 @@ public static function spanKindProvider(): array
public function test_span_with_error_status(): void
{
$span = (new SpanData())->setStatus(StatusData::error());
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidArgument,PossiblyNullReference */
$row = (new SpanConverter())->convert([$span])->getResourceSpans()[0]->getScopeSpans()[0]->getSpans()[0];
$this->assertSame(V1\Status\StatusCode::STATUS_CODE_ERROR, $row->getStatus()->getCode());
}
Expand Down
Loading