Class: Datadog::Statsd::Schema::SchemaBuilder::MetricBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/statsd/schema/schema_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Helper class for building individual metrics with block syntax

Since:

  • 0.1.0

API:

  • private

Instance Method Summary collapse

Constructor Details

#initialize(metric_def) ⇒ MetricBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize with a metric definition

Parameters:

  • Initial metric definition

Since:

  • 0.1.0

API:

  • private



336
337
338
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 336

def initialize(metric_def)
  @metric_def = metric_def
end

Instance Method Details

#buildMetricDefinition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build the final metric definition

Returns:

  • The constructed metric definition

Since:

  • 0.1.0

API:

  • private



378
379
380
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 378

def build
  @metric_def
end

#description(desc) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Set metric description

Parameters:

  • Description text

Since:

  • 0.1.0

API:

  • private



343
344
345
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 343

def description(desc)
  @metric_def = @metric_def.new(description: desc)
end

#inherit_tags(metric_path) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Set metric inheritance

Parameters:

  • Path to parent metric

Since:

  • 0.1.0

API:

  • private



372
373
374
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 372

def inherit_tags(metric_path)
  @metric_def = @metric_def.new(inherit_tags: metric_path)
end

#tags(**options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Configure metric tags

Parameters:

  • Tag configuration

Options Hash (**options):

  • :allowed (Array)

    Allowed tag names

  • :required (Array)

    Required tag names

Since:

  • 0.1.0

API:

  • private



352
353
354
355
356
357
358
359
360
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 352

def tags(**options)
  allowed = Array(options[:allowed] || []).map(&:to_sym)
  required = Array(options[:required] || []).map(&:to_sym)

  @metric_def = @metric_def.new(
    allowed_tags: allowed,
    required_tags: required
  )
end

#units(unit_name) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Set metric units

Parameters:

  • Unit description

Since:

  • 0.1.0

API:

  • private



365
366
367
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 365

def units(unit_name)
  @metric_def = @metric_def.new(units: unit_name)
end