summaryrefslogtreecommitdiff
path: root/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ConstSamplerTest.php
blob: 85cb805041cbbaea356d5fc72081c97496177b08 (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
<?php

namespace Jaeger\Tests\Sampler;

use Jaeger\Sampler\ConstSampler;
use PHPUnit\Framework\TestCase;
use const Jaeger\SAMPLER_PARAM_TAG_KEY;
use const Jaeger\SAMPLER_TYPE_CONST;
use const Jaeger\SAMPLER_TYPE_TAG_KEY;

class ConstSamplerTest extends TestCase
{
    /**
     * @test
     * @dataProvider samplerProvider
     * @param bool $decision
     * @param mixed $traceId
     */
    public function shouldDetermineWhetherOrTraceShouldBeSampled($decision, $traceId)
    {
        $sampler = new ConstSampler($decision);

        list($sampled, $tags) = $sampler->isSampled($traceId);

        $this->assertEquals($decision, $sampled);
        $this->assertEquals([
            SAMPLER_TYPE_TAG_KEY  => SAMPLER_TYPE_CONST,
            SAMPLER_PARAM_TAG_KEY => $decision,
        ], $tags);

        $sampler->close();
    }

    public function samplerProvider()
    {
        return [
            [true,  1],
            [true,  PHP_INT_MAX],
            [false, 1],
            [false, PHP_INT_MAX],
        ];
    }
}