File: const.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 (24 lines) | stat: -rw-r--r-- 556 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
# frozen_string_literal: true

module Jaeger
  module Samplers
    # Const sampler
    #
    # A sampler that always makes the same decision for new traces depending
    # on the initialization value. Use `Jaeger::Samplers::Const.new(true)`
    # to mark all new traces as sampled.
    class Const
      def initialize(decision)
        @decision = decision
        @tags = {
          'sampler.type' => 'const',
          'sampler.param' => @decision ? 1 : 0
        }
      end

      def sample(*)
        [@decision, @tags]
      end
    end
  end
end