Skip to content

Commit d4c4470

Browse files
jerrytfleungbrettmcNevay
authored
feat: Add experimental response propagator interface (#1712)
* Added experimental response propagator * Added response propagator interface to Globals * changed to experimental_response_propagator * Update src/API/Globals.php Co-authored-by: Brett McBride <[email protected]> * Update src/Context/Propagation/ResponsePropagatorInterface.php Co-authored-by: Brett McBride <[email protected]> * Update src/Config/SDK/ComponentProvider/OpenTelemetrySdk.php Co-authored-by: Tobias Bachert <[email protected]> * Changed experimental_response_propagator to response_propagator/development * Cleaned up the comment * Bumped context and api version * Bumped open-telemetry/sdk in open-telemetry/sdk-configuration --------- Co-authored-by: Brett McBride <[email protected]> Co-authored-by: Tobias Bachert <[email protected]>
1 parent 438f718 commit d4c4470

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenTelemetry\Context\Propagation;
6+
7+
use OpenTelemetry\Context\ContextInterface;
8+
9+
/**
10+
* @experimental
11+
*/
12+
final class MultiResponsePropagator implements ResponsePropagatorInterface
13+
{
14+
/**
15+
* @no-named-arguments
16+
*
17+
* @param list<ResponsePropagatorInterface> $responsePropagators
18+
*/
19+
public function __construct(
20+
private readonly array $responsePropagators,
21+
) {
22+
}
23+
24+
#[\Override]
25+
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
26+
{
27+
foreach ($this->responsePropagators as $responsePropagator) {
28+
$responsePropagator->inject($carrier, $setter, $context);
29+
}
30+
}
31+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenTelemetry\Context\Propagation;
6+
7+
use OpenTelemetry\Context\ContextInterface;
8+
9+
/**
10+
* @experimental
11+
*/
12+
final class NoopResponsePropagator implements ResponsePropagatorInterface
13+
{
14+
private static ?self $instance = null;
15+
16+
public static function getInstance(): self
17+
{
18+
if (null === self::$instance) {
19+
self::$instance = new self();
20+
}
21+
22+
return self::$instance;
23+
}
24+
25+
#[\Override]
26+
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
27+
{
28+
}
29+
}
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\Context\Propagation;
6+
7+
use OpenTelemetry\Context\ContextInterface;
8+
9+
/**
10+
* @experimental
11+
*/
12+
interface ResponsePropagatorInterface
13+
{
14+
/**
15+
* Injects specific values from the provided {@see ContextInterface} into the provided carrier
16+
* via an {@see PropagationSetterInterface}.
17+
*
18+
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.48.0/specification/context/api-propagators.md#textmap-inject
19+
* @experimental
20+
*/
21+
public function inject(mixed &$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void;
22+
}

0 commit comments

Comments
 (0)