File: const_spec.rb

package info (click to toggle)
ruby-jaeger-client 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 624 kB
  • sloc: ruby: 3,381; makefile: 6; sh: 4
file content (39 lines) | stat: -rw-r--r-- 936 bytes parent folder | download
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
require 'spec_helper'

RSpec.describe Jaeger::Samplers::Const do
  let(:sampler) { described_class.new(decision) }
  let(:sample_args) { { trace_id: Jaeger::TraceId.generate } }
  let(:sample_result) { sampler.sample(sample_args) }
  let(:is_sampled) { sample_result[0] }
  let(:tags) { sample_result[1] }

  context 'when decision is set to true' do
    let(:decision) { true }

    it 'sets sampling to always true' do
      expect(is_sampled).to eq(true)
    end

    it 'returns tags with param 1' do
      expect(tags).to eq(
        'sampler.type' => 'const',
        'sampler.param' => 1
      )
    end
  end

  context 'when decision is set to false' do
    let(:decision) { false }

    it 'sets sampling to always false' do
      expect(is_sampled).to eq(false)
    end

    it 'returns tags with param 0' do
      expect(tags).to eq(
        'sampler.type' => 'const',
        'sampler.param' => 0
      )
    end
  end
end