Class: Datadog::Tracing::Configuration::Dynamic::TracingSamplingRules
- Inherits:
-
SimpleOption
- Object
- Option
- SimpleOption
- Datadog::Tracing::Configuration::Dynamic::TracingSamplingRules
- Defined in:
- lib/datadog/tracing/configuration/dynamic.rb
Overview
Dynamic configuration for ‘DD_TRACE_SAMPLING_RULES`.
Instance Attribute Summary
Attributes inherited from Option
Instance Method Summary collapse
-
#call(tracing_sampling_rules) ⇒ Object
Ensures sampler is rebuilt and new configuration is applied.
-
#initialize ⇒ TracingSamplingRules
constructor
A new instance of TracingSamplingRules.
Constructor Details
#initialize ⇒ TracingSamplingRules
Returns a new instance of TracingSamplingRules.
58 59 60 |
# File 'lib/datadog/tracing/configuration/dynamic.rb', line 58 def initialize super('tracing_sampling_rules', 'DD_TRACE_SAMPLING_RULES', :rules) end |
Instance Method Details
#call(tracing_sampling_rules) ⇒ Object
Ensures sampler is rebuilt and new configuration is applied
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/datadog/tracing/configuration/dynamic.rb', line 63 def call(tracing_sampling_rules) # Modify the remote configuration value that it matches the # local environment variable it configures. if tracing_sampling_rules tracing_sampling_rules.each do |rule| next unless ( = rule['tags']) # Tag maps come in as arrays of 'key' and `value_glob`. # We need to convert them into a hash for local use. tag_array = .map! do |tag| [tag['key'], tag['value_glob']] end rule['tags'] = tag_array.to_h end # The configuration is stored as JSON, so we need to convert it back tracing_sampling_rules = tracing_sampling_rules.to_json end super(tracing_sampling_rules) Datadog.send(:components).reconfigure_live_sampler end |