2 * Copyright (c) 2017 Uber Technologies, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef JAEGERTRACING_CONFIG_H
18 #define JAEGERTRACING_CONFIG_H
20 #include "jaegertracing/Compilers.h"
21 #include "jaegertracing/Constants.h"
22 #include "jaegertracing/Tag.h"
23 #include "jaegertracing/baggage/RestrictionsConfig.h"
24 #include "jaegertracing/propagation/HeadersConfig.h"
25 #include "jaegertracing/reporters/Config.h"
26 #include "jaegertracing/samplers/Config.h"
27 #include "jaegertracing/utils/YAML.h"
29 namespace jaegertracing
{
34 static constexpr auto kJAEGER_SERVICE_NAME_ENV_PROP
= "JAEGER_SERVICE_NAME";
35 static constexpr auto kJAEGER_TAGS_ENV_PROP
= "JAEGER_TAGS";
36 static constexpr auto kJAEGER_JAEGER_DISABLED_ENV_PROP
= "JAEGER_DISABLED";
38 #ifdef JAEGERTRACING_WITH_YAML_CPP
40 static Config
parse(const YAML::Node
& configYAML
)
42 if (!configYAML
.IsDefined() || !configYAML
.IsMap()) {
46 const auto serviceName
=
47 utils::yaml::findOrDefault
<std::string
>(configYAML
, "service_name", "");
50 utils::yaml::findOrDefault
<bool>(configYAML
, "disabled", false);
51 const auto samplerNode
= configYAML
["sampler"];
52 const auto sampler
= samplers::Config::parse(samplerNode
);
53 const auto reporterNode
= configYAML
["reporter"];
54 const auto reporter
= reporters::Config::parse(reporterNode
);
55 const auto headersNode
= configYAML
["headers"];
56 const auto headers
= propagation::HeadersConfig::parse(headersNode
);
57 const auto baggageRestrictionsNode
= configYAML
["baggage_restrictions"];
58 const auto baggageRestrictions
=
59 baggage::RestrictionsConfig::parse(baggageRestrictionsNode
);
61 disabled
, sampler
, reporter
, headers
, baggageRestrictions
, serviceName
);
64 #endif // JAEGERTRACING_WITH_YAML_CPP
66 explicit Config(bool disabled
= false,
67 const samplers::Config
& sampler
= samplers::Config(),
68 const reporters::Config
& reporter
= reporters::Config(),
69 const propagation::HeadersConfig
& headers
=
70 propagation::HeadersConfig(),
71 const baggage::RestrictionsConfig
& baggageRestrictions
=
72 baggage::RestrictionsConfig(),
73 const std::string
& serviceName
= "",
74 const std::vector
<Tag
>& tags
= std::vector
<Tag
>())
76 , _serviceName(serviceName
)
81 , _baggageRestrictions(baggageRestrictions
)
85 bool disabled() const { return _disabled
; }
87 const samplers::Config
& sampler() const { return _sampler
; }
89 const reporters::Config
& reporter() const { return _reporter
; }
91 const propagation::HeadersConfig
& headers() const { return _headers
; }
93 const baggage::RestrictionsConfig
& baggageRestrictions() const
95 return _baggageRestrictions
;
98 const std::string
& serviceName() const { return _serviceName
; }
100 const std::vector
<Tag
>& tags() const { return _tags
; }
106 std::string _serviceName
;
107 std::vector
< Tag
> _tags
;
108 samplers::Config _sampler
;
109 reporters::Config _reporter
;
110 propagation::HeadersConfig _headers
;
111 baggage::RestrictionsConfig _baggageRestrictions
;
114 } // namespace jaegertracing
116 #endif // JAEGERTRACING_CONFIG_H