Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4136034
CompositePropagator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
CompositePropagator.php
View Options
<?php
namespace
Wikimedia\Telemetry
;
use
Wikimedia\Assert\Assert
;
use
Wikimedia\Assert\ParameterAssertionException
;
/**
* CompositePropagator accepts an array of other propagators.
* It delegates to each of them in order when extracting or injecting.
* When extracting, it returns the first non-null result.
*/
class
CompositePropagator
implements
ContextPropagatorInterface
{
/** @var ContextPropagatorInterface[] */
private
$propagators
;
/**
* @param ContextPropagatorInterface[] $propagators
* @throws ParameterAssertionException if $propagators is empty
*/
public
function
__construct
(
array
$propagators
)
{
Assert
::
parameter
(
count
(
$propagators
)
>
0
,
'$propagators'
,
'must not be empty'
);
$this
->
propagators
=
$propagators
;
}
/**
* @inheritDoc
*/
public
function
extract
(
array
$carrier
):
?
SpanContext
{
foreach
(
$this
->
propagators
as
$propagator
)
{
$context
=
$propagator
->
extract
(
$carrier
);
if
(
$context
!==
null
)
{
return
$context
;
}
}
return
null
;
}
/**
* @inheritDoc
*/
public
function
inject
(
?
SpanContext
$context
,
array
$carrier
):
array
{
foreach
(
$this
->
propagators
as
$propagator
)
{
$carrier
=
$propagator
->
inject
(
$context
,
$carrier
);
}
return
$carrier
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 13:30 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7e/81/da9bae27c4ed9c36baf6b08aab2a
Default Alt Text
CompositePropagator.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment