Skip to content

Commit 7934662

Browse files
authored
feat(telemetry): include NGINX flavor in telemetry (#205)
* feat(telemetry): include NGINX flavor in telemetry This commit enhances telemetry by adding the NGINX flavor into the integration name reported. This improvement will provide better insights into how the module is utilized. Changes: - Fix reported flavor for openresty. - Report integration name depending of the flavor.
1 parent aee0a7a commit 7934662

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ build-openresty-aux:
153153
-DNGINX_PATCH_AWAY_LIBC=ON \
154154
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
155155
-DNGINX_SRC_DIR=/tmp/openresty-${RESTY_VERSION}/build/nginx-${NGINX_VERSION} \
156+
-DNGINX_DATADOG_FLAVOR="openresty" \
156157
-DNGINX_DATADOG_ASM_ENABLED="$(WAF)" . \
157158
&& cmake --build .openresty-build -j $(MAKE_JOB_COUNT) -v --target ngx_http_datadog_module \
158159

src/nginx_flavors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ inline constexpr flavor from_str(std::string_view in) {
1414
if (in == "nginx") {
1515
return flavor::vanilla;
1616
} else if (in == "openresty") {
17-
return flavor::vanilla;
17+
return flavor::openresty;
1818
} else if (in == "ingress-nginx") {
1919
return flavor::ingress_nginx;
2020
}

src/tracing_library.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,27 @@ extern "C" {
3131
namespace datadog {
3232
namespace nginx {
3333

34+
inline constexpr std::string_view integration_name_from_flavor(
35+
flavor nginx_flavor) {
36+
switch (nginx_flavor) {
37+
case flavor::vanilla:
38+
return "nginx";
39+
case flavor::openresty:
40+
return "nginx:openresty";
41+
case flavor::ingress_nginx:
42+
return "nginx:ingress-nginx";
43+
}
44+
45+
static_assert(true, "unknown NGINX flavor");
46+
std::abort();
47+
}
48+
3449
dd::Expected<dd::Tracer> TracingLibrary::make_tracer(
3550
const datadog_main_conf_t &nginx_conf, std::shared_ptr<dd::Logger> logger) {
3651
dd::TracerConfig config;
3752
config.logger = std::move(logger);
3853
config.agent.event_scheduler = std::make_shared<NgxEventScheduler>();
39-
config.integration_name = "nginx";
54+
config.integration_name = integration_name_from_flavor(kNginx_flavor);
4055
config.integration_version = NGINX_VERSION;
4156
config.service = "nginx";
4257

0 commit comments

Comments
 (0)