class OpenCensus::Trace::Formatters::CloudTrace
This formatter serializes and deserializes span context according to the Google X-Cloud-Trace header specification.
Constants
Public Instance Methods
deserialize(header)
click to toggle source
Deserialize a trace context header into a TraceContext
object.
@param [String] header @return [TraceContextData, nil]
# File lib/opencensus/trace/formatters/cloud_trace.rb, line 72 def deserialize header match = HEADER_FORMAT.match(header) if match trace_id = match[1].downcase span_id = format("%016x", match[2].to_i) trace_options = match[3].to_i TraceContextData.new trace_id, span_id, trace_options else nil end end
header_name()
click to toggle source
Returns the name of the header used for context propagation.
@return [String]
# File lib/opencensus/trace/formatters/cloud_trace.rb, line 52 def header_name HEADER_NAME end
rack_header_name()
click to toggle source
Returns the name of the rack_environment header to use when parsing context from an incoming request.
@return [String]
# File lib/opencensus/trace/formatters/cloud_trace.rb, line 62 def rack_header_name RACK_HEADER_NAME end
serialize(trace_context)
click to toggle source
Serialize a TraceContextData object.
@param [TraceContextData] trace_context @return [String]
# File lib/opencensus/trace/formatters/cloud_trace.rb, line 90 def serialize trace_context trace_context.trace_id.dup.tap do |ret| if trace_context.span_id ret << "/" << trace_context.span_id.to_i(16).to_s end if trace_context.trace_options ret << ";o=" << trace_context.trace_options.to_s end end end