Class: OpenCensus::Tags::TagMap
- Inherits:
-
Object
- Object
- OpenCensus::Tags::TagMap
- Extended by:
- Forwardable
- Defined in:
- lib/opencensus/tags/tag_map.rb
Overview
TagMap
Collection of tag key and value.
Defined Under Namespace
Classes: InvalidTagError
Constant Summary collapse
- MAX_LENGTH =
The maximum length for a tag key and tag value
255
Class Method Summary collapse
-
.from_binary(data) ⇒ TagMap
Create a tag map from the binary string.
Instance Method Summary collapse
- #[] ⇒ Object
-
#[]=(key, value) ⇒ Object
Set tag key value.
- #delete ⇒ Object
- #delete_if ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Object
-
#initialize(tags = {}) ⇒ TagMap
constructor
Create a tag map.
- #length ⇒ Object
-
#to_binary ⇒ String
Convert tag map to binary string format.
- #to_h ⇒ Object
Constructor Details
#initialize(tags = {}) ⇒ TagMap
Create a tag map. It is a map of tags from key to value.
47 48 49 50 51 52 53 |
# File 'lib/opencensus/tags/tag_map.rb', line 47 def initialize = {} @tags = {} .each do |key, value| self[key] = value end end |
Class Method Details
.from_binary(data) ⇒ TagMap
Create a tag map from the binary string.
80 81 82 |
# File 'lib/opencensus/tags/tag_map.rb', line 80 def self.from_binary data Formatters::Binary.new.deserialize data end |
Instance Method Details
#[] ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#[]=(key, value) ⇒ Object
Set tag key value
61 62 63 64 65 66 |
# File 'lib/opencensus/tags/tag_map.rb', line 61 def []= key, value validate_key! key validate_value! value @tags[key] = value end |
#delete ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#delete_if ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#each ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#empty? ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#length ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |
#to_binary ⇒ String
Convert tag map to binary string format.
72 73 74 |
# File 'lib/opencensus/tags/tag_map.rb', line 72 def to_binary Formatters::Binary.new.serialize self end |
#to_h ⇒ Object
98 99 |
# File 'lib/opencensus/tags/tag_map.rb', line 98 def_delegators :@tags, :[], :each, :delete, :delete_if, :length, \ :to_h, :empty? |