Class: Zipkin::Encoders::JsonEncoder
- Inherits:
-
Object
- Object
- Zipkin::Encoders::JsonEncoder
- Defined in:
- lib/zipkin/encoders/json_encoder.rb,
lib/zipkin/encoders/json_encoder/timestamp.rb,
lib/zipkin/encoders/json_encoder/log_annotations.rb
Defined Under Namespace
Modules: Fields, JsonAdapter, LogAnnotations, OjAdapter, Timestamp
Constant Summary collapse
- OT_KIND_TO_ZIPKIN_KIND =
{ 'server' => 'SERVER', 'client' => 'CLIENT', 'producer' => 'PRODUCER', 'consumer' => 'CONSUMER' }.freeze
- CONTENT_TYPE =
'application/json'.freeze
Instance Method Summary collapse
- #content_type ⇒ Object
- #encode(spans) ⇒ Object
-
#initialize(local_endpoint) ⇒ JsonEncoder
constructor
A new instance of JsonEncoder.
Constructor Details
#initialize(local_endpoint) ⇒ JsonEncoder
Returns a new instance of JsonEncoder.
43 44 45 46 |
# File 'lib/zipkin/encoders/json_encoder.rb', line 43 def initialize(local_endpoint) @adapter = defined?(Oj) ? OjAdapter : JsonAdapter @local_endpoint = serialize_endpoint(local_endpoint) end |
Instance Method Details
#content_type ⇒ Object
48 49 50 |
# File 'lib/zipkin/encoders/json_encoder.rb', line 48 def content_type CONTENT_TYPE end |
#encode(spans) ⇒ Object
52 53 54 |
# File 'lib/zipkin/encoders/json_encoder.rb', line 52 def encode(spans) @adapter.dump(spans.map(&method(:serialize))) end |