Module: Datadog::Tracing::Remote

Defined in:
lib/datadog/tracing/remote.rb

Overview

Remote configuration declaration

Defined Under Namespace

Classes: ReadError

Constant Summary collapse

PRODUCT =
'APM_TRACING'
CAPABILITIES =
[
  1 << 12, # APM_TRACING_SAMPLE_RATE: Dynamic trace sampling rate configuration
  1 << 13, # APM_TRACING_LOGS_INJECTION: Dynamic trace logs injection configuration
  1 << 14, # APM_TRACING_HTTP_HEADER_TAGS: Dynamic trace HTTP header tags configuration
  1 << 29, # APM_TRACING_SAMPLE_RULES: Dynamic trace sampling rules configuration
].freeze

Class Method Summary collapse

Class Method Details

.capabilitiesObject



26
27
28
# File 'lib/datadog/tracing/remote.rb', line 26

def capabilities
  CAPABILITIES
end

.process_config(config, content) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/datadog/tracing/remote.rb', line 30

def process_config(config, content)
  lib_config = config['lib_config']

  env_vars = Datadog::Tracing::Configuration::Dynamic::OPTIONS.map do |name, env_var, option|
    value = lib_config[name]

    # Guard for RBS/Steep
    raise "option is a #{option.class}, expected Option" unless option.is_a?(Configuration::Dynamic::Option)

    option.call(value)

    [env_var, value]
  end

  content.applied

  Datadog.send(:components).telemetry.client_configuration_change!(env_vars)
rescue => e
  content.errored("#{e.class.name} #{e.message}: #{Array(e.backtrace).join("\n")}")
end

.productsObject



22
23
24
# File 'lib/datadog/tracing/remote.rb', line 22

def products
  [PRODUCT]
end

.receiver(products = [PRODUCT], &block) ⇒ Object



66
67
68
69
# File 'lib/datadog/tracing/remote.rb', line 66

def receiver(products = [PRODUCT], &block)
  matcher = Core::Remote::Dispatcher::Matcher::Product.new(products)
  [Core::Remote::Dispatcher::Receiver.new(matcher, &block)]
end

.receivers(_telemetry) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/datadog/tracing/remote.rb', line 51

def receivers(_telemetry)
  receiver do |repository, _changes|
    # DEV: Filter our by product. Given it will be very common
    # DEV: we can filter this out before we receive the data in this method.
    # DEV: Apply this refactor to AppSec as well if implemented.
    repository.contents.map do |content|
      case content.path.product
      when PRODUCT
        config = parse_content(content)
        process_config(config, content)
      end
    end
  end
end