Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/extensions/filters/network/thrift_proxy/tracing.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <list>
4
#include <string>
5
6
#include "absl/types/optional.h"
7
8
namespace Envoy {
9
namespace Extensions {
10
namespace NetworkFilters {
11
namespace ThriftProxy {
12
13
/**
14
 * Endpoint is an endpoint attribution on an Annotation or BinaryAnnotation.
15
 */
16
class Endpoint {
17
public:
18
  Endpoint(int32_t ipv4, int16_t port, const std::string& service_name)
19
0
      : ipv4_(ipv4), port_(port), service_name_(service_name) {}
20
0
  Endpoint() = default;
21
22
  int32_t ipv4_{0};
23
  int16_t port_{0};
24
  std::string service_name_;
25
};
26
27
/**
28
 * Annotation is a span annotation.
29
 */
30
class Annotation {
31
public:
32
  Annotation(int64_t timestamp, const std::string& value, absl::optional<Endpoint> host)
33
0
      : timestamp_(timestamp), value_(value), host_(host) {}
34
0
  Annotation() = default;
35
36
  int64_t timestamp_{0};
37
  std::string value_;
38
  absl::optional<Endpoint> host_;
39
};
40
using AnnotationList = std::list<Annotation>;
41
42
/**
43
 * AnnotationType represents a BinaryAnnotation's type.
44
 */
45
enum class AnnotationType {
46
  Bool = 0,
47
  Bytes = 1,
48
  I16 = 2,
49
  I32 = 3,
50
  I64 = 4,
51
  Double = 5,
52
  String = 6,
53
};
54
55
/**
56
 * BinaryAnnotation is a binary span annotation.
57
 */
58
class BinaryAnnotation {
59
public:
60
  BinaryAnnotation(const std::string& key, const std::string& value, AnnotationType annotation_type,
61
                   absl::optional<Endpoint> host)
62
0
      : key_(key), value_(value), annotation_type_(annotation_type), host_(host) {}
63
0
  BinaryAnnotation() = default;
64
65
  std::string key_;
66
  std::string value_;
67
  AnnotationType annotation_type_{AnnotationType::Bool};
68
  absl::optional<Endpoint> host_;
69
};
70
using BinaryAnnotationList = std::list<BinaryAnnotation>;
71
72
/**
73
 * Span is a single, annotated span in a trace.
74
 */
75
class Span {
76
public:
77
  Span(int64_t trace_id, const std::string& name, int64_t span_id,
78
       absl::optional<int64_t> parent_span_id, AnnotationList&& annotations,
79
       BinaryAnnotationList&& binary_annotations, bool debug)
80
      : trace_id_(trace_id), name_(name), span_id_(span_id), parent_span_id_(parent_span_id),
81
        annotations_(std::move(annotations)), binary_annotations_(std::move(binary_annotations)),
82
0
        debug_(debug) {}
83
0
  Span() = default;
84
85
  int64_t trace_id_{0};
86
  std::string name_;
87
  int64_t span_id_{0};
88
  absl::optional<int64_t> parent_span_id_;
89
  AnnotationList annotations_;
90
  BinaryAnnotationList binary_annotations_;
91
  bool debug_{false};
92
};
93
using SpanList = std::list<Span>;
94
95
} // namespace ThriftProxy
96
} // namespace NetworkFilters
97
} // namespace Extensions
98
} // namespace Envoy