Class: Datadog::Encoding::Encoder
- Inherits:
-
Object
- Object
- Datadog::Encoding::Encoder
- Defined in:
- lib/ddtrace/encoding.rb
Overview
Encoder interface that provides the logic to encode traces and service
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
-
#encode(_) ⇒ Object
Defines the underlying format used during traces or services encoding.
-
#encode_services(services) ⇒ Object
Encodes services hash.
-
#encode_traces(traces) ⇒ Object
Encodes a list of traces, expecting a list of items where each items is a list of spans.
-
#initialize ⇒ Encoder
constructor
When extending the “Encoder“ class, “content_type“ must be set because they’re used by the HTTPTransport so that it should not need to know what is the right header to suggest the decoding format to the agent.
Constructor Details
#initialize ⇒ Encoder
When extending the “Encoder“ class, “content_type“ must be set because they’re used by the HTTPTransport so that it should not need to know what is the right header to suggest the decoding format to the agent
14 15 16 |
# File 'lib/ddtrace/encoding.rb', line 14 def initialize @content_type = '' end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/ddtrace/encoding.rb', line 9 def content_type @content_type end |
Instance Method Details
#encode(_) ⇒ Object
Defines the underlying format used during traces or services encoding. This method must be implemented and should only be used by the internal functions.
36 37 38 |
# File 'lib/ddtrace/encoding.rb', line 36 def encode(_) raise NotImplementedError end |
#encode_services(services) ⇒ Object
Encodes services hash
30 31 32 |
# File 'lib/ddtrace/encoding.rb', line 30 def encode_services(services) encode(services) end |
#encode_traces(traces) ⇒ Object
Encodes a list of traces, expecting a list of items where each items is a list of spans. Before dump the string in a serialized format all traces are normalized. The traces nesting is not changed.
21 22 23 24 25 26 27 |
# File 'lib/ddtrace/encoding.rb', line 21 def encode_traces(traces) to_send = [] traces.each do |trace| to_send << trace.map(&:to_hash) end encode(to_send) end |