LCOV - code coverage report
Current view: top level - source/extensions/tracers/zipkin - span_context.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 9 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 9 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <regex>
       4             : 
       5             : #include "source/extensions/tracers/zipkin/util.h"
       6             : #include "source/extensions/tracers/zipkin/zipkin_core_constants.h"
       7             : #include "source/extensions/tracers/zipkin/zipkin_core_types.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Extensions {
      11             : namespace Tracers {
      12             : namespace Zipkin {
      13             : 
      14             : /**
      15             :  * This class represents the context of a Zipkin span. It embodies the following
      16             :  * span characteristics: trace id, span id, parent id, and basic annotations.
      17             :  */
      18             : class SpanContext {
      19             : public:
      20             :   /**
      21             :    * Default constructor. Creates an empty context.
      22             :    */
      23           0 :   SpanContext() = default;
      24             : 
      25             :   /**
      26             :    * Constructor that creates a context object from the supplied trace, span and
      27             :    * parent ids, and sampled flag.
      28             :    *
      29             :    * @param trace_id_high The high 64 bits of the trace id.
      30             :    * @param trace_id The low 64 bits of the trace id.
      31             :    * @param id The span id.
      32             :    * @param parent_id The parent id.
      33             :    * @param sampled The sampled flag.
      34             :    * @param inner_context If this context is created base on the inner span.
      35             :    */
      36             :   SpanContext(const uint64_t trace_id_high, const uint64_t trace_id, const uint64_t id,
      37             :               const uint64_t parent_id, bool sampled, bool inner_context = false)
      38             :       : trace_id_high_(trace_id_high), trace_id_(trace_id), id_(id), parent_id_(parent_id),
      39           0 :         sampled_(sampled), inner_context_(inner_context) {}
      40             : 
      41             :   /**
      42             :    * Constructor that creates a context object from the given Zipkin span object.
      43             :    *
      44             :    * @param span The Zipkin span used to initialize a SpanContext object.
      45             :    * @param inner_context If this context is created base on the inner span.
      46             :    */
      47             :   SpanContext(const Span& span, bool inner_context = true);
      48             : 
      49             :   /**
      50             :    * @return the span id as an integer
      51             :    */
      52           0 :   uint64_t id() const { return id_; }
      53             : 
      54             :   /**
      55             :    * @return the span's parent id as an integer.
      56             :    */
      57           0 :   uint64_t parentId() const { return parent_id_; }
      58             : 
      59             :   /**
      60             :    * @return the high 64 bits of the trace id as an integer.
      61             :    */
      62           0 :   uint64_t traceIdHigh() const { return trace_id_high_; }
      63             : 
      64             :   /**
      65             :    * @return the low 64 bits of the trace id as an integer.
      66             :    */
      67           0 :   uint64_t traceId() const { return trace_id_; }
      68             : 
      69             :   /**
      70             :    * @return whether using 128 bit trace id.
      71             :    */
      72           0 :   bool is128BitTraceId() const { return trace_id_high_ != 0; }
      73             : 
      74             :   /**
      75             :    * @return the sampled flag.
      76             :    */
      77           0 :   bool sampled() const { return sampled_; }
      78             : 
      79             :   /**
      80             :    * @return the inner context flag.
      81             :    */
      82           0 :   bool innerContext() const { return inner_context_; }
      83             : 
      84             : private:
      85             :   const uint64_t trace_id_high_{0};
      86             :   const uint64_t trace_id_{0};
      87             :   const uint64_t id_{0};
      88             :   const uint64_t parent_id_{0};
      89             :   const bool sampled_{false};
      90             :   const bool inner_context_{false};
      91             : };
      92             : 
      93             : } // namespace Zipkin
      94             : } // namespace Tracers
      95             : } // namespace Extensions
      96             : } // namespace Envoy

Generated by: LCOV version 1.15