Class: XRay::Annotations

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/aws-xray-sdk/model/annotations.rb

Overview

Annotations are simple key-value pairs that are indexed for use with filter expressions. Use annotations to record data that you want to use to group traces in the console, or when calling the GetTraceSummaries API.

Instance Method Summary collapse

Methods included from Logging

#logger, logger, logger=

Constructor Details

#initialize(entity) ⇒ Annotations

Returns a new instance of Annotations.



11
12
13
14
# File 'lib/aws-xray-sdk/model/annotations.rb', line 11

def initialize(entity)
  @entity = entity
  @data = {}
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
# File 'lib/aws-xray-sdk/model/annotations.rb', line 16

def [](key)
  @data[key]
end

#[]=(k, v) ⇒ Object

Parameters:

  • k (Symbol)

    Only characters in ‘A-Za-z0-9_` are supported.

  • v

    Only ‘Numeric`, `String` true/false is supported.

Raises:



22
23
24
25
26
27
28
29
# File 'lib/aws-xray-sdk/model/annotations.rb', line 22

def []=(k, v)
  raise EntityClosedError if @entity.closed?
  if key_supported?(k) && value_supported?(v)
    @data[k] = v
  else
    logger.warn %(Dropping annotation with key #{k} due to invalid characters.)
  end
end

#to_hObject



38
39
40
# File 'lib/aws-xray-sdk/model/annotations.rb', line 38

def to_h
  sanitize_values(@data)
end

#update(h) ⇒ Object

Parameters:

  • h (Hash)

    Update annotations with a single input hash.

Raises:



32
33
34
35
36
# File 'lib/aws-xray-sdk/model/annotations.rb', line 32

def update(h)
  raise EntityClosedError if @entity.closed?
  filtered = filter_annotations(h)
  @data.merge!(filtered)
end