Class: RubyZipkin::MetadataLogger
- Inherits:
-
Object
- Object
- RubyZipkin::MetadataLogger
- Defined in:
- lib/rubyzipkin/metadata_logger.rb
Class Method Summary collapse
-
.log(key, value, max_size_bytes = 512) ⇒ Object
log a key value pair into a zipkin trace as a KV span value since logging can ve quite extensive, we set a cap for the max size in bytes for a trace header.
-
.log_request(headers) ⇒ Object
Do a full dump of a request header into zipkin.
Class Method Details
.log(key, value, max_size_bytes = 512) ⇒ Object
log a key value pair into a zipkin trace as a KV span value since logging can ve quite extensive, we set a cap for the max size in bytes for a trace header
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rubyzipkin/metadata_logger.rb', line 10 def self.log(key, value, max_size_bytes = 512) if key.to_s == "action_controller.rescue.request" || key.to_s == "action_controller.rescue.response" ann = ::Trace::BinaryAnnotation.new(key, value.as_json.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint) puts ann.to_s ::Trace.record(ann) else ann = ::Trace::BinaryAnnotation.new(key, value.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint) ::Trace.record(ann) end end |
.log_request(headers) ⇒ Object
Do a full dump of a request header into zipkin.
22 23 24 25 26 27 28 |
# File 'lib/rubyzipkin/metadata_logger.rb', line 22 def self.log_request(headers) if headers headers.each do |header, value| MetadataLogger.log("HEADER_#{header}", value) end end end |