blob: 7c6ba3d62ec65b8a546b671787adf04d1eb24863 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
namespace Jaeger\Sampler;
use const Jaeger\SAMPLER_PARAM_TAG_KEY;
use const Jaeger\SAMPLER_TYPE_CONST;
use const Jaeger\SAMPLER_TYPE_TAG_KEY;
/**
* ConstSampler always returns the same decision.
*
* @package Jaeger\Sampler
*/
class ConstSampler implements SamplerInterface
{
/**
* Whether or not the new trace should be sampled.
*
* @var bool
*/
private $decision;
/**
* A list of the sampler tags.
*
* @var array
*/
private $tags = [];
/**
* ConstSampler constructor.
*
* @param bool $decision
*/
public function __construct(bool $decision = true)
{
$this->tags = [
SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_CONST,
SAMPLER_PARAM_TAG_KEY => $decision,
];
$this->decision = $decision;
}
/**
* {@inheritdoc}
*
* @param string $traceId The traceId on the span.
* @param string $operation The operation name set on the span.
* @return array
*/
public function isSampled(string $traceId, string $operation = ''): array
{
return [$this->decision, $this->tags];
}
/**
* {@inheritdoc}
*
* Only implemented to satisfy the sampler interface.
*
* @return void
*/
public function close()
{
// nothing to do
}
}
|