Module: Datadog::Metrics::Options

Included in:
Datadog::Metrics, Datadog::Metrics
Defined in:
lib/ddtrace/metrics.rb

Overview

For defining and adding default options to metrics

Constant Summary collapse

DEFAULT =
{
  tags: DEFAULT_TAGS = [
    "#{Ext::Metrics::TAG_LANG}:#{Runtime::Identity.lang}".freeze,
    "#{Ext::Metrics::TAG_LANG_INTERPRETER}:#{Runtime::Identity.lang_interpreter}".freeze,
    "#{Ext::Metrics::TAG_LANG_VERSION}:#{Runtime::Identity.lang_version}".freeze,
    "#{Ext::Metrics::TAG_TRACER_VERSION}:#{Runtime::Identity.tracer_version}".freeze
  ].freeze
}.freeze

Instance Method Summary collapse

Instance Method Details

#default_metric_optionsObject



149
150
151
152
153
154
155
# File 'lib/ddtrace/metrics.rb', line 149

def default_metric_options
  # Return dupes, so that the constant isn't modified,
  # and defaults are unfrozen for mutation in Statsd.
  DEFAULT.dup.tap do |options|
    options[:tags] = options[:tags].dup
  end
end

#metric_options(options = nil) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/ddtrace/metrics.rb', line 136

def metric_options(options = nil)
  return default_metric_options if options.nil?

  default_metric_options.merge(options) do |key, old_value, new_value|
    case key
    when :tags
      old_value.dup.concat(new_value).uniq
    else
      new_value
    end
  end
end