1
#include "source/extensions/tracers/opentelemetry/samplers/always_on/always_on_sampler.h"
2

            
3
#include <memory>
4
#include <sstream>
5
#include <string>
6

            
7
#include "source/common/config/datasource.h"
8
#include "source/extensions/tracers/opentelemetry/span_context.h"
9

            
10
namespace Envoy {
11
namespace Extensions {
12
namespace Tracers {
13
namespace OpenTelemetry {
14

            
15
SamplingResult AlwaysOnSampler::shouldSample(const StreamInfo::StreamInfo&,
16
                                             const absl::optional<SpanContext> parent_context,
17
                                             const std::string& /*trace_id*/,
18
                                             const std::string& /*name*/, OTelSpanKind /*kind*/,
19
                                             OptRef<const Tracing::TraceContext> /*trace_context*/,
20
5
                                             const std::vector<SpanContext>& /*links*/) {
21
5
  SamplingResult result;
22
5
  result.decision = Decision::RecordAndSample;
23
5
  if (parent_context.has_value()) {
24
3
    result.tracestate = parent_context.value().tracestate();
25
3
  }
26
5
  return result;
27
5
}
28

            
29
2
std::string AlwaysOnSampler::getDescription() const { return "AlwaysOnSampler"; }
30

            
31
} // namespace OpenTelemetry
32
} // namespace Tracers
33
} // namespace Extensions
34
} // namespace Envoy