MediaWiki master
CompositePropagator.php
Go to the documentation of this file.
1<?php
2namespace Wikimedia\Telemetry;
3
4use Wikimedia\Assert\Assert;
5use Wikimedia\Assert\ParameterAssertionException;
6
14 private $propagators;
15
20 public function __construct( array $propagators ) {
21 Assert::parameter(
22 count( $propagators ) > 0,
23 '$propagators',
24 'must not be empty'
25 );
26 $this->propagators = $propagators;
27 }
28
32 public function extract( array $carrier ): ?SpanContext {
33 foreach ( $this->propagators as $propagator ) {
34 $context = $propagator->extract( $carrier );
35 if ( $context !== null ) {
36 return $context;
37 }
38 }
39 return null;
40 }
41
45 public function inject( ?SpanContext $context, array $carrier ): array {
46 foreach ( $this->propagators as $propagator ) {
47 $carrier = $propagator->inject( $context, $carrier );
48 }
49 return $carrier;
50 }
51}
CompositePropagator accepts an array of other propagators.
extract(array $carrier)
Attempt to extract a SpanContext from the given carrier.
inject(?SpanContext $context, array $carrier)
Inject the given SpanContext into the given carrier.SpanContext may be null, in which case the propag...
Data transfer object holding data associated with a given span.
Interface for classes to serialize and deserialize SpanContexts to and from implementation-specific a...