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}:#{Core::Environment::Identity.lang}".freeze,
    "#{Ext::Metrics::TAG_LANG_INTERPRETER}:#{Core::Environment::Identity.lang_interpreter}".freeze,
    "#{Ext::Metrics::TAG_LANG_VERSION}:#{Core::Environment::Identity.lang_version}".freeze,
    "#{Ext::Metrics::TAG_TRACER_VERSION}:#{Core::Environment::Identity.tracer_version}".freeze
  ].freeze
}.freeze

Instance Method Summary collapse

Instance Method Details

#default_metric_optionsObject



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/ddtrace/metrics.rb', line 183

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

    env = Datadog.configuration.env
    options[:tags] << "#{Datadog::Ext::Environment::TAG_ENV}:#{env}" unless env.nil?

    version = Datadog.configuration.version
    options[:tags] << "#{Datadog::Ext::Environment::TAG_VERSION}:#{version}" unless version.nil?
  end
end

#metric_options(options = nil) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/ddtrace/metrics.rb', line 170

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