module OpenCensus::Tags

The Tags module contains support for OpenCensus tags. Tags are key-value pairs. Tags provide additional cardinality to the OpenCensus instrumentation data.

Constants

TAG_MAP_CONTEXT_KEY

Internal key for storing the current TagMap in the thread local Context

@private

Attributes

config[R]

Get the current configuration @private

Public Class Methods

configure() { |config| ... } click to toggle source

Configure OpenCensus Tags. These configuration fields include parameters formatter.

This configuration is also available as the `tags` subconfig under the main configuration `OpenCensus.configure`. If the OpenCensus Railtie is installed in a Rails application, the configuration object is also exposed as `config.opencensus.tags`.

Generally, you should configure this once at process initialization, but it can be modified at any time.

Supported fields are:

  • `binary_formatter` The tags context propagation formatter to use. Must be a formatter, an object with `serialize`, `deserialize`, methods. See {OpenCensus::Tags::Formatters::Binary}.

@example

OpenCensus::Tags.configure do |config|
  config.binary_formatter = OpenCensus::Tags::Formatters::Binary.new
end
# File lib/opencensus/tags/config.rb, line 59
def configure
  if block_given?
    yield @config
  else
    @config
  end
end
tag_map_context() click to toggle source

Returns the current thread-local TagMap object.

@return [TagMap, nil]

# File lib/opencensus/tags.rb, line 58
def tag_map_context
  OpenCensus::Context.get TAG_MAP_CONTEXT_KEY
end
tag_map_context=(context) click to toggle source

Sets the current thread-local TagMap, which used in Stats data recording.

@param [TagMap] context

# File lib/opencensus/tags.rb, line 44
def tag_map_context= context
  OpenCensus::Context.set TAG_MAP_CONTEXT_KEY, context
end
unset_tag_map_context() click to toggle source

Unsets the current thread-local TagMap context

# File lib/opencensus/tags.rb, line 50
def unset_tag_map_context
  OpenCensus::Context.unset TAG_MAP_CONTEXT_KEY
end