diff --git a/src/tracing_library.cpp b/src/tracing_library.cpp index ab1e1010..ffec9daf 100644 --- a/src/tracing_library.cpp +++ b/src/tracing_library.cpp @@ -35,10 +35,12 @@ std::string_view or_default(std::string_view config_json) { } // namespace -dd::Expected TracingLibrary::make_tracer(const datadog_main_conf_t& nginx_conf) { +dd::Expected TracingLibrary::make_tracer(const datadog_main_conf_t &nginx_conf) { dd::TracerConfig config; config.logger = std::make_shared(); config.agent.event_scheduler = std::make_shared(); + config.integration_name = "nginx"; + config.integration_version = NGINX_VERSION; if (!nginx_conf.propagation_styles.empty()) { config.injection_styles = config.extraction_styles = nginx_conf.propagation_styles; @@ -71,11 +73,11 @@ dd::Expected TracingLibrary::make_tracer(const datadog_main_conf_t& // order in which we try the rules doesn't change the outcome. // Deeper directives are more likely to match a given request, though, and // so this can be thought of as an optimization. - const auto by_depth_descending = [](const auto& left, const auto& right) { + const auto by_depth_descending = [](const auto &left, const auto &right) { return *left.depth > *right.depth; }; std::stable_sort(rules.begin(), rules.end(), by_depth_descending); - for (sampling_rule_t& rule : rules) { + for (sampling_rule_t &rule : rules) { config.trace_sampler.rules.push_back(std::move(rule.rule)); } @@ -88,7 +90,7 @@ dd::Expected TracingLibrary::make_tracer(const datadog_main_conf_t& } dd::Expected> TracingLibrary::propagation_header_names( - const std::vector& configured_styles, dd::Logger& logger) { + const std::vector &configured_styles, dd::Logger &logger) { std::vector result; // Create a tracer config that contains `configured_styles` (or the default @@ -105,16 +107,19 @@ dd::Expected> TracingLibrary::propagation_header_n minimal_config.extraction_styles = configured_styles; } auto finalized_config = dd::finalize_config(minimal_config); - if (auto* error = finalized_config.if_error()) { + if (auto *error = finalized_config.if_error()) { return std::move(*error); } if (!configured_styles.empty() && configured_styles != finalized_config->injection_styles) { - logger.log_error([&](std::ostream& log) { - log << "Actual injection propagation styles differ from that specified in the nginx " - "configuration. The datadog_propagation_styles directive indicated the values " + logger.log_error([&](std::ostream &log) { + log << "Actual injection propagation styles differ from that specified " + "in the nginx " + "configuration. The datadog_propagation_styles directive " + "indicated the values " << dd::to_json(configured_styles) - << ", but after applying environment variables, the final values are instead " + << ", but after applying environment variables, the final values are " + "instead " << dd::to_json(finalized_config->injection_styles); }); } @@ -179,10 +184,10 @@ class SpanContextJSONWriter : public dd::DictWriter { output_object_[std::move(normalized_key)] = value; } - nlohmann::json& json() { return output_object_; } + nlohmann::json &json() { return output_object_; } }; -std::string span_property(std::string_view key, const dd::Span& span) { +std::string span_property(std::string_view key, const dd::Span &span) { const auto not_found = "-"; if (key == "trace_id") {