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 RecordAndSample 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
8
                           Server::Configuration::TracerFactoryContext& /*context*/) {}
25
  SamplingResult shouldSample(const StreamInfo::StreamInfo& stream_info,
26
                              const absl::optional<SpanContext> parent_context,
27
                              const std::string& trace_id, const std::string& name,
28
                              OTelSpanKind spankind,
29
                              OptRef<const Tracing::TraceContext> trace_context,
30
                              const std::vector<SpanContext>& links) override;
31
  std::string getDescription() const override;
32

            
33
private:
34
};
35

            
36
} // namespace OpenTelemetry
37
} // namespace Tracers
38
} // namespace Extensions
39
} // namespace Envoy