Method: Datadog::Tracing::Sampling::Span::RuleParser.parse_list
- Defined in:
- lib/datadog/tracing/sampling/span/rule_parser.rb
.parse_list(rules) ⇒ Array<Datadog::Tracing::Sampling::Span::Rule>?
Parses a list of Hashes containing the parsed JSON information for Single Span Sampling configuration. In case of parsing errors, ‘nil` is returned.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/datadog/tracing/sampling/span/rule_parser.rb', line 47 def parse_list(rules) unless rules.is_a?(Array) Datadog.logger.warn("Span Sampling Rules are not an array: #{rules.inspect}") return nil end parsed = rules.map do |hash| unless hash.is_a?(Hash) Datadog.logger.warn("Span Sampling Rule is not a key-value object: #{hash.inspect}") return nil end begin parse_rule(hash) rescue => e Datadog.logger.warn( "Cannot parse Span Sampling Rule #{hash.inspect}: " \ "#{e.class.name} #{e} at #{Array(e.backtrace).first}" ) return nil end end parsed.compact! parsed end |