Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/server/factory_context.h" 4 : 5 : #include "source/common/common/logger.h" 6 : #include "source/common/config/datasource.h" 7 : #include "source/extensions/tracers/opentelemetry/samplers/sampler.h" 8 : 9 : namespace Envoy { 10 : namespace Extensions { 11 : namespace Tracers { 12 : namespace OpenTelemetry { 13 : 14 : /** 15 : * @brief A sampler which samples every span. 16 : * https://opentelemetry.io/docs/specs/otel/trace/sdk/#alwayson 17 : * - Returns RECORD_AND_SAMPLE always. 18 : * - Description MUST be AlwaysOnSampler. 19 : * 20 : */ 21 : class AlwaysOnSampler : public Sampler, Logger::Loggable<Logger::Id::tracing> { 22 : public: 23 : explicit AlwaysOnSampler(const Protobuf::Message& /*config*/, 24 0 : Server::Configuration::TracerFactoryContext& /*context*/) {} 25 : SamplingResult shouldSample(const absl::optional<SpanContext> parent_context, 26 : const std::string& trace_id, const std::string& name, 27 : OTelSpanKind spankind, 28 : OptRef<const Tracing::TraceContext> trace_context, 29 : const std::vector<SpanContext>& links) override; 30 : std::string getDescription() const override; 31 : 32 : private: 33 : }; 34 : 35 : } // namespace OpenTelemetry 36 : } // namespace Tracers 37 : } // namespace Extensions 38 : } // namespace Envoy