Skip to content

Commit 610b79a

Browse files
authored
Implement span suppression strategies (#1599)
* Implement span suppression strategies Noop: does not suppress anything SpanKind: suppresses nested spans with the same span kind (except for internal) SemConv: attempts to guess and suppress the semantic convention that is represented by the span * Fix style * Add `experimental`/`internal` annotation * Move `SpanSuppressionStrategy` and related classes to SDK * Update examples to avoid usage of internal classes * Move `SpanSuppression` namespace to `API\Trace` * Add override attributes * Prefilter semantic conventions based on sampling relevant attributes * Add basic span suppression test * Only inspect sampling relevant attributes * Inverse attribute masks * Ignore extra attributes if otherwise no semconv is matched * Return singletons where possible * Bump API dependency * Fix span kinds without semantic conventions
1 parent ee17d93 commit 610b79a

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

Trace/Span.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final public function activate(): ScopeInterface
5858

5959
/** @inheritDoc */
6060
#[\Override]
61-
final public function storeInContext(ContextInterface $context): ContextInterface
61+
public function storeInContext(ContextInterface $context): ContextInterface
6262
{
6363
if (LocalRootSpan::isLocalRoot($context)) {
6464
$context = LocalRootSpan::store($context, $this);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenTelemetry\API\Trace\SpanSuppression;
6+
7+
/**
8+
* @experimental
9+
*/
10+
final class SemanticConvention
11+
{
12+
/**
13+
* @param list<string> $samplingAttributes
14+
*/
15+
public function __construct(
16+
public readonly string $name,
17+
public readonly int $spanKind,
18+
public readonly array $samplingAttributes,
19+
public readonly array $attributes,
20+
) {
21+
}
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenTelemetry\API\Trace\SpanSuppression;
6+
7+
/**
8+
* @experimental
9+
*/
10+
interface SemanticConventionResolver
11+
{
12+
/**
13+
* @return list<SemanticConvention>
14+
*/
15+
public function resolveSemanticConventions(string $name, ?string $version, ?string $schemaUrl): array;
16+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"extra": {
3737
"branch-alias": {
38-
"dev-main": "1.4.x-dev"
38+
"dev-main": "1.7.x-dev"
3939
},
4040
"spi": {
4141
"OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [

0 commit comments

Comments
 (0)