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

            
3
#include <memory>
4

            
5
#include "envoy/extensions/tracers/opentelemetry/samplers/v3/dynatrace_sampler.pb.validate.h"
6

            
7
#include "source/common/config/utility.h"
8
#include "source/common/protobuf/utility.h"
9
#include "source/extensions/tracers/opentelemetry/samplers/dynatrace/dynatrace_sampler.h"
10

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

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

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

            
26
5
  SamplerConfigProviderPtr cf = std::make_unique<SamplerConfigProviderImpl>(context, proto_config);
27
5
  return std::make_shared<DynatraceSampler>(proto_config, context, std::move(cf));
28
5
}
29

            
30
/**
31
 * Static registration for the Dynatrace sampler factory. @see RegisterFactory.
32
 */
33
REGISTER_FACTORY(DynatraceSamplerFactory, SamplerFactory);
34

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