Skip to content

Commit b2266f6

Browse files
dmehaladgoffredo
andauthored
feat: Set integration informations (#59)
* feat: Set integration informations * run `make format` --------- Co-authored-by: David Goffredo <[email protected]>
1 parent 06a59c4 commit b2266f6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/tracing_library.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ std::string_view or_default(std::string_view config_json) {
3535

3636
} // namespace
3737

38-
dd::Expected<dd::Tracer> TracingLibrary::make_tracer(const datadog_main_conf_t& nginx_conf) {
38+
dd::Expected<dd::Tracer> TracingLibrary::make_tracer(const datadog_main_conf_t &nginx_conf) {
3939
dd::TracerConfig config;
4040
config.logger = std::make_shared<NgxLogger>();
4141
config.agent.event_scheduler = std::make_shared<NgxEventScheduler>();
42+
config.integration_name = "nginx";
43+
config.integration_version = NGINX_VERSION;
4244

4345
if (!nginx_conf.propagation_styles.empty()) {
4446
config.injection_styles = config.extraction_styles = nginx_conf.propagation_styles;
@@ -71,11 +73,11 @@ dd::Expected<dd::Tracer> TracingLibrary::make_tracer(const datadog_main_conf_t&
7173
// order in which we try the rules doesn't change the outcome.
7274
// Deeper directives are more likely to match a given request, though, and
7375
// so this can be thought of as an optimization.
74-
const auto by_depth_descending = [](const auto& left, const auto& right) {
76+
const auto by_depth_descending = [](const auto &left, const auto &right) {
7577
return *left.depth > *right.depth;
7678
};
7779
std::stable_sort(rules.begin(), rules.end(), by_depth_descending);
78-
for (sampling_rule_t& rule : rules) {
80+
for (sampling_rule_t &rule : rules) {
7981
config.trace_sampler.rules.push_back(std::move(rule.rule));
8082
}
8183

@@ -88,7 +90,7 @@ dd::Expected<dd::Tracer> TracingLibrary::make_tracer(const datadog_main_conf_t&
8890
}
8991

9092
dd::Expected<std::vector<std::string_view>> TracingLibrary::propagation_header_names(
91-
const std::vector<dd::PropagationStyle>& configured_styles, dd::Logger& logger) {
93+
const std::vector<dd::PropagationStyle> &configured_styles, dd::Logger &logger) {
9294
std::vector<std::string_view> result;
9395

9496
// Create a tracer config that contains `configured_styles` (or the default
@@ -105,16 +107,19 @@ dd::Expected<std::vector<std::string_view>> TracingLibrary::propagation_header_n
105107
minimal_config.extraction_styles = configured_styles;
106108
}
107109
auto finalized_config = dd::finalize_config(minimal_config);
108-
if (auto* error = finalized_config.if_error()) {
110+
if (auto *error = finalized_config.if_error()) {
109111
return std::move(*error);
110112
}
111113

112114
if (!configured_styles.empty() && configured_styles != finalized_config->injection_styles) {
113-
logger.log_error([&](std::ostream& log) {
114-
log << "Actual injection propagation styles differ from that specified in the nginx "
115-
"configuration. The datadog_propagation_styles directive indicated the values "
115+
logger.log_error([&](std::ostream &log) {
116+
log << "Actual injection propagation styles differ from that specified "
117+
"in the nginx "
118+
"configuration. The datadog_propagation_styles directive "
119+
"indicated the values "
116120
<< dd::to_json(configured_styles)
117-
<< ", but after applying environment variables, the final values are instead "
121+
<< ", but after applying environment variables, the final values are "
122+
"instead "
118123
<< dd::to_json(finalized_config->injection_styles);
119124
});
120125
}
@@ -179,10 +184,10 @@ class SpanContextJSONWriter : public dd::DictWriter {
179184
output_object_[std::move(normalized_key)] = value;
180185
}
181186

182-
nlohmann::json& json() { return output_object_; }
187+
nlohmann::json &json() { return output_object_; }
183188
};
184189

185-
std::string span_property(std::string_view key, const dd::Span& span) {
190+
std::string span_property(std::string_view key, const dd::Span &span) {
186191
const auto not_found = "-";
187192

188193
if (key == "trace_id") {

0 commit comments

Comments
 (0)