1
#include "source/extensions/tracers/opentelemetry/samplers/trace_id_ratio_based/config.h"
2

            
3
#include "envoy/extensions/tracers/opentelemetry/samplers/v3/trace_id_ratio_based_sampler.pb.h"
4
#include "envoy/extensions/tracers/opentelemetry/samplers/v3/trace_id_ratio_based_sampler.pb.validate.h"
5
#include "envoy/server/tracer_config.h"
6

            
7
#include "source/common/config/utility.h"
8
#include "source/extensions/tracers/opentelemetry/samplers/trace_id_ratio_based/trace_id_ratio_based_sampler.h"
9

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

            
15
SamplerSharedPtr TraceIdRatioBasedSamplerFactory::createSampler(
16
8
    const Protobuf::Message& config, Server::Configuration::TracerFactoryContext& context) {
17
8
  auto mptr = Envoy::Config::Utility::translateAnyToFactoryConfig(
18
8
      dynamic_cast<const Protobuf::Any&>(config), context.messageValidationVisitor(), *this);
19

            
20
8
  const auto& proto_config =
21
8
      MessageUtil::downcastAndValidate<const envoy::extensions::tracers::opentelemetry::samplers::
22
8
                                           v3::TraceIdRatioBasedSamplerConfig&>(
23
8
          *mptr, context.messageValidationVisitor());
24

            
25
8
  return std::make_shared<TraceIdRatioBasedSampler>(proto_config, context);
26
8
}
27

            
28
/**
29
 * Static registration for the Env sampler factory. @see RegisterFactory.
30
 */
31
REGISTER_FACTORY(TraceIdRatioBasedSamplerFactory, SamplerFactory);
32

            
33
} // namespace OpenTelemetry
34
} // namespace Tracers
35
} // namespace Extensions
36
} // namespace Envoy