Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/tracing/custom_tag.h" 4 : 5 : namespace Envoy { 6 : namespace Tracing { 7 : 8 : constexpr uint32_t DefaultMaxPathTagLength = 256; 9 : 10 : enum class OperationName { Ingress, Egress }; 11 : 12 : /** 13 : * Tracing configuration, it carries additional data needed to populate the span. 14 : */ 15 : class Config { 16 : public: 17 699 : virtual ~Config() = default; 18 : 19 : /** 20 : * @return operation name for tracing, e.g., ingress. 21 : */ 22 : virtual OperationName operationName() const PURE; 23 : 24 : /** 25 : * @return create separated child span for upstream request if true. 26 : */ 27 : virtual bool spawnUpstreamSpan() const PURE; 28 : 29 : /** 30 : * @return custom tags to be attached to the active span. 31 : */ 32 : virtual const CustomTagMap* customTags() const PURE; 33 : 34 : /** 35 : * @return true if spans should be annotated with more detailed information. 36 : */ 37 : virtual bool verbose() const PURE; 38 : 39 : /** 40 : * @return the maximum length allowed for paths in the extracted HttpUrl tag. This is only used 41 : * for HTTP protocol tracing. 42 : */ 43 : virtual uint32_t maxPathTagLength() const PURE; 44 : }; 45 : 46 : /** 47 : * Route or connection manager level tracing configuration. 48 : */ 49 : class TracingConfig { 50 : public: 51 0 : virtual ~TracingConfig() = default; 52 : 53 : /** 54 : * This method returns the client sampling percentage. 55 : * @return the client sampling percentage 56 : */ 57 : virtual const envoy::type::v3::FractionalPercent& getClientSampling() const PURE; 58 : 59 : /** 60 : * This method returns the random sampling percentage. 61 : * @return the random sampling percentage 62 : */ 63 : virtual const envoy::type::v3::FractionalPercent& getRandomSampling() const PURE; 64 : 65 : /** 66 : * This method returns the overall sampling percentage. 67 : * @return the overall sampling percentage 68 : */ 69 : virtual const envoy::type::v3::FractionalPercent& getOverallSampling() const PURE; 70 : 71 : /** 72 : * This method returns the tracing custom tags. 73 : * @return the tracing custom tags. 74 : */ 75 : virtual const Tracing::CustomTagMap& getCustomTags() const PURE; 76 : }; 77 : 78 : /** 79 : * Connection manager tracing configuration. 80 : */ 81 : class ConnectionManagerTracingConfig : public TracingConfig { 82 : public: 83 : /** 84 : * @return operation name for tracing, e.g., ingress. 85 : */ 86 : virtual OperationName operationName() const PURE; 87 : 88 : /** 89 : * @return create separated child span for upstream request if true. 90 : */ 91 : virtual bool spawnUpstreamSpan() const PURE; 92 : 93 : /** 94 : * @return true if spans should be annotated with more detailed information. 95 : */ 96 : virtual bool verbose() const PURE; 97 : 98 : /** 99 : * @return the maximum length allowed for paths in the extracted HttpUrl tag. This is only used 100 : * for HTTP protocol tracing. 101 : */ 102 : virtual uint32_t maxPathTagLength() const PURE; 103 : }; 104 : 105 : using ConnectionManagerTracingConfigPtr = std::unique_ptr<ConnectionManagerTracingConfig>; 106 : 107 : } // namespace Tracing 108 : } // namespace Envoy