summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Trace/SamplingResult.php
blob: 5701b7bc61726aba36d298dba02fa643ac1fc7ee (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
69
70
71
<?php

declare(strict_types=1);

namespace OpenTelemetry\SDK\Trace;

use OpenTelemetry\API\Trace as API;

final class SamplingResult
{
    /**
     * Span will not be recorded and all events and attributes will be dropped.
     */
    public const DROP = 0;

    /**
     * Span will be recorded but SpanExporters will not receive this Span.
     */
    public const RECORD_ONLY = 1;

    /**
     * Span will be recorder and exported.
     */
    public const RECORD_AND_SAMPLE = 2;

    /**
     * @var int A sampling Decision.
     */
    private int $decision;

    /**
     * @var iterable A set of span Attributes that will also be added to the Span.
     */
    private iterable $attributes;

    /**
     * @var ?API\TraceStateInterface A Tracestate that will be associated with the Span through the new SpanContext.
     */
    private ?API\TraceStateInterface $traceState;

    public function __construct(int $decision, iterable $attributes = [], ?API\TraceStateInterface $traceState = null)
    {
        $this->decision = $decision;
        $this->attributes = $attributes;
        $this->traceState = $traceState;
    }

    /**
     * Return sampling decision whether span should be recorded or not.
     */
    public function getDecision(): int
    {
        return $this->decision;
    }

    /**
     * Return attributes which will be attached to the span.
     */
    public function getAttributes(): iterable
    {
        return $this->attributes;
    }

    /**
     * Return a collection of links that will be associated with the Span to be created.
     */
    public function getTraceState(): ?API\TraceStateInterface
    {
        return $this->traceState;
    }
}