Class: Datadog::Statsd::Schema::SchemaBuilder::NamespaceBuilder 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 namespaces within the DSL

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, transformers = {}) ⇒ NamespaceBuilder

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 a new namespace builder

Parameters:

  • name (Symbol)

    Name of the namespace

  • transformers (Hash) (defaults to: {})

    Available transformer functions

Since:

  • 0.1.0



145
146
147
148
149
150
151
152
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 145

def initialize(name, transformers = {})
  @name = name.to_sym
  @transformers = transformers
  @tags = {}
  @metrics = {}
  @namespaces = {}
  @description = nil
end

Instance Attribute Details

#description(desc) ⇒ void (readonly)

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 description for this namespace

Parameters:

  • desc (String)

    Description text

Since:

  • 0.1.0



140
141
142
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 140

def description
  @description
end

#metrics {|MetricsBuilder| ... } ⇒ void (readonly)

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.

Define metrics for this namespace

Examples:

metrics do
  counter :page_views, tags: { required: [:controller] }
  gauge :memory_usage
end

Yields:

Since:

  • 0.1.0



132
133
134
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 132

def metrics
  @metrics
end

#nameSymbol (readonly)

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.

Name of the namespace being built

Returns:

  • (Symbol)

    Namespace name

Since:

  • 0.1.0



120
121
122
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 120

def name
  @name
end

#namespacesHash<Symbol, Namespace> (readonly)

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.

Nested namespaces

Returns:

  • (Hash<Symbol, Namespace>)

    Nested namespace definitions

Since:

  • 0.1.0



136
137
138
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 136

def namespaces
  @namespaces
end

#tags {|TagsBuilder| ... } ⇒ void (readonly)

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.

Define tags for this namespace

Examples:

tags do
  tag :controller, values: %w[users posts]
  tag :action, values: %w[index show create]
end

Yields:

Since:

  • 0.1.0



128
129
130
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 128

def tags
  @tags
end

#transformersHash<Symbol, Proc> (readonly)

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.

Available transformers for tags

Returns:

  • (Hash<Symbol, Proc>)

    Transformer definitions

Since:

  • 0.1.0



124
125
126
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 124

def transformers
  @transformers
end

Instance Method Details

#buildNamespace

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 namespace instance

Returns:

Since:

  • 0.1.0



197
198
199
200
201
202
203
204
205
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 197

def build
  Namespace.new(
    name: @name,
    description: @description,
    tags: @tags,
    metrics: @metrics,
    namespaces: @namespaces
  )
end

#namespace(name) {|NamespaceBuilder| ... } ⇒ 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.

Define nested namespace

Parameters:

  • name (Symbol)

    Name of the nested namespace

Yields:

Since:

  • 0.1.0



189
190
191
192
193
# File 'lib/datadog/statsd/schema/schema_builder.rb', line 189

def namespace(name, &)
  builder = NamespaceBuilder.new(name, @transformers)
  builder.instance_eval(&) if block_given?
  @namespaces[name.to_sym] = builder.build
end