From fd07069221b6c0b04210da2c9f7fc2e5cb77bf35 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Wed, 22 Jan 2025 18:26:26 -0800 Subject: [PATCH 1/7] Add "dogstatsd_non_local_traffic: true" to the agent image and start testing runtime metrics by observing what metrics the agent is sending to the backend --- manifests/cpp.yml | 1 + manifests/dotnet.yml | 3 +- manifests/golang.yml | 3 +- manifests/java.yml | 2 + manifests/nodejs.yml | 1 + manifests/php.yml | 1 + manifests/python.yml | 2 + manifests/ruby.yml | 3 +- tests/test_config_consistency.py | 58 +++++++++++++++++++++------ utils/_context/_scenarios/__init__.py | 1 + utils/build/docker/agent.Dockerfile | 1 + utils/interfaces/_agent.py | 16 ++++++++ 12 files changed, 77 insertions(+), 15 deletions(-) diff --git a/manifests/cpp.yml b/manifests/cpp.yml index c89f9876419..5b1efc33e05 100644 --- a/manifests/cpp.yml +++ b/manifests/cpp.yml @@ -253,6 +253,7 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Empty: missing_feature Test_Config_RuntimeMetrics_Default: missing_feature Test_Config_RuntimeMetrics_Enabled: missing_feature + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: missing_feature Test_Config_UnifiedServiceTagging_Default: missing_feature test_distributed.py: diff --git a/manifests/dotnet.yml b/manifests/dotnet.yml index a6e22bec4cc..cac105aaff7 100644 --- a/manifests/dotnet.yml +++ b/manifests/dotnet.yml @@ -496,7 +496,8 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Default: v3.4.1 Test_Config_ObfuscationQueryStringRegexp_Empty: v3.4.1 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for dotnet runtime metrics) - Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for dotnet runtime metrics) + Test_Config_RuntimeMetrics_Enabled: v2.0.0 + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: v2.0.0 Test_Config_UnifiedServiceTagging_CustomService: v3.3.0 Test_Config_UnifiedServiceTagging_Default: v3.3.0 test_data_integrity.py: diff --git a/manifests/golang.yml b/manifests/golang.yml index 492e23ee6f4..4fa99667f71 100644 --- a/manifests/golang.yml +++ b/manifests/golang.yml @@ -600,7 +600,8 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Default: v1.67.0 Test_Config_ObfuscationQueryStringRegexp_Empty: v1.67.0 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for golang runtime metrics) - Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for golang runtime metrics) + Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (should be in v1.18.0 but we're not receiving series in tests) + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: incomplete_test_app (should be in v1.18.0 but we're not receiving series in tests) Test_Config_UnifiedServiceTagging_CustomService: v1.67.0 Test_Config_UnifiedServiceTagging_Default: v1.67.0 test_data_integrity.py: diff --git a/manifests/java.yml b/manifests/java.yml index 2be67925162..6e36e060abc 100644 --- a/manifests/java.yml +++ b/manifests/java.yml @@ -1712,6 +1712,8 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Empty: v1.39.0 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for java runtime metrics) Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for java runtime metrics) + Test_Config_RuntimeMetrics_Enabled: v0.64.0 + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: v0.64.0 Test_Config_UnifiedServiceTagging_CustomService: v1.39.0 Test_Config_UnifiedServiceTagging_Default: v1.39.0 test_data_integrity.py: diff --git a/manifests/nodejs.yml b/manifests/nodejs.yml index 367a7af5d55..94ae9af0d37 100644 --- a/manifests/nodejs.yml +++ b/manifests/nodejs.yml @@ -860,6 +860,7 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Empty: *ref_3_0_0 Test_Config_RuntimeMetrics_Default: *ref_3_0_0 Test_Config_RuntimeMetrics_Enabled: *ref_3_0_0 + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: *ref_5_25_0 Test_Config_UnifiedServiceTagging_Default: *ref_5_25_0 test_distributed.py: diff --git a/manifests/php.yml b/manifests/php.yml index e29087da723..6f800fddea7 100644 --- a/manifests/php.yml +++ b/manifests/php.yml @@ -479,6 +479,7 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Empty: v1.5.0 Test_Config_RuntimeMetrics_Default: missing_feature Test_Config_RuntimeMetrics_Enabled: missing_feature + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: v1.4.0 Test_Config_UnifiedServiceTagging_Default: v1.4.0 test_distributed.py: diff --git a/manifests/python.yml b/manifests/python.yml index 4352e7b47eb..acdd922d88b 100644 --- a/manifests/python.yml +++ b/manifests/python.yml @@ -895,6 +895,8 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Empty: v2.15.0 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for python runtime metrics) Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for python runtime metrics) + Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (Python seems to send sketches instead of gauges/counters) + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: v2.0.0 Test_Config_UnifiedServiceTagging_Default: v2.0.0 test_data_integrity.py: diff --git a/manifests/ruby.yml b/manifests/ruby.yml index b2d7ded6a1e..264a3350adb 100644 --- a/manifests/ruby.yml +++ b/manifests/ruby.yml @@ -498,7 +498,8 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Default: bug (APMAPI-1013) Test_Config_ObfuscationQueryStringRegexp_Empty: missing_feature (environment variable is not supported) Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for ruby runtime metrics) - Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for ruby runtime metrics) + Test_Config_RuntimeMetrics_Enabled: missing_feature (should be in v0.44.0 but we're not receiving series in tests) + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: v2.0.0 Test_Config_UnifiedServiceTagging_Default: v2.0.0 test_distributed.py: diff --git a/tests/test_config_consistency.py b/tests/test_config_consistency.py index 83aebef435b..1761c328f99 100644 --- a/tests/test_config_consistency.py +++ b/tests/test_config_consistency.py @@ -4,12 +4,14 @@ import re import json +import time from utils import weblog, interfaces, scenarios, features, rfc, irrelevant, context, bug, missing_feature from utils.tools import logger # get the default log output stdout = interfaces.library_stdout if context.library != "dotnet" else interfaces.library_dotnet_managed runtime_metrics = {"nodejs": "runtime.node.mem.heap_total"} +runtime_metrics_langs = [".NET", "go", "nodejs", "python", "ruby"] log_injection_fields = {"nodejs": {"message": "msg"}} @@ -555,19 +557,51 @@ def test_log_injection_128bit_traceid_disabled(self): @scenarios.runtime_metrics_enabled @features.tracing_configuration_consistency class Test_Config_RuntimeMetrics_Enabled: - """Verify runtime metrics are enabled when DD_RUNTIME_METRICS_ENABLED=true""" + """Verify runtime metrics are enabled when DD_RUNTIME_METRICS_ENABLED=true and that they have the proper tags""" - # This test verifies runtime metrics by asserting the prescene of a metric in the dogstatsd endpoint - def test_config_runtimemetrics_enabled(self): - for data in interfaces.library.get_data("/dogstatsd/v2/proxy"): - lines = data["request"]["content"].split("\n") - metric_found = False - for line in lines: - if runtime_metrics[context.library.library] in line: - metric_found = True - break - assert metric_found, f"The metric {runtime_metrics[context.library.library]} was not found in any line" - break + def setup_main(self): + self.req = weblog.get("/") + + def test_main(self): + assert self.req.status_code == 200 + + time.sleep(12) + runtime_metrics = [metric for _, metric in interfaces.agent.get_metrics(request=self.req) if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")] + assert len(runtime_metrics) > 0 + + for metric in runtime_metrics: + tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"] } + assert tags.get("lang") in runtime_metrics_langs or tags.get("lang") is None + + # Test that Unified Service Tags are added to the runtime metrics + assert tags["service"] == "weblog" + assert tags["env"] == "system-tests" + assert tags["version"] == "1.0.0" + + # Test that DD_TAGS are added to the runtime metrics + # DD_TAGS=key1:val1,key2:val2 in default weblog containers + assert tags["key1"] == "val1" + assert tags["key2"] == "val2" + + +@scenarios.runtime_metrics_enabled +@features.tracing_configuration_consistency +class Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: + """Verify runtime metrics are enabled when DD_RUNTIME_METRICS_ENABLED=true and that they have the runtime-id tag""" + + def setup_main(self): + self.req = weblog.get("/") + + def test_main(self): + assert self.req.status_code == 200 + + time.sleep(12) + runtime_metrics = [metric for _, metric in interfaces.agent.get_metrics(request=self.req) if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")] + assert len(runtime_metrics) > 0 + + for metric in runtime_metrics: + tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"] } + assert "runtime-id" in tags @rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp") diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index b70eb648b4d..a64e87e27bb 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -784,6 +784,7 @@ class _Scenarios: runtime_metrics_enabled = EndToEndScenario( "RUNTIME_METRICS_ENABLED", runtime_metrics_enabled=True, + use_proxy_for_weblog=False, doc="Test runtime metrics", ) diff --git a/utils/build/docker/agent.Dockerfile b/utils/build/docker/agent.Dockerfile index 6d73d96f803..b39208a3668 100644 --- a/utils/build/docker/agent.Dockerfile +++ b/utils/build/docker/agent.Dockerfile @@ -10,6 +10,7 @@ RUN set -eux;\ # Datadog agent conf RUN echo '\ log_level: DEBUG\n\ +dogstatsd_non_local_traffic: true\n\ apm_config:\n\ apm_non_local_traffic: true\n\ trace_buffer: 5\n\ diff --git a/utils/interfaces/_agent.py b/utils/interfaces/_agent.py index fac292abec4..6eabf540b19 100644 --- a/utils/interfaces/_agent.py +++ b/utils/interfaces/_agent.py @@ -143,6 +143,22 @@ def get_spans(self, request=None): def get_spans_list(self, request): return [span for _, span in self.get_spans(request)] + def get_metrics(self, request=None): + """Attempts to fetch the spans the agent will submit to the backend. + + When a valid request is given, then we filter the spans to the ones sampled + during that request's execution, and only return those. + """ + + for data in self.get_data(path_filters="/api/v2/series"): + if "series" not in data["request"]["content"]: + raise ValueError("series property is missing in agent payload") + + content = data["request"]["content"]["series"] + + for point in content: + yield data, point + def get_dsm_data(self): return self.get_data(path_filters="/api/v0.1/pipeline_stats") From 3514cf28e7946dcdc3476fb797e21270350bf547 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Thu, 23 Jan 2025 15:55:06 -0800 Subject: [PATCH 2/7] Fix linting issues --- tests/test_config_consistency.py | 16 ++++++++++++---- utils/interfaces/_agent.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/test_config_consistency.py b/tests/test_config_consistency.py index 1761c328f99..1d7a21c3d17 100644 --- a/tests/test_config_consistency.py +++ b/tests/test_config_consistency.py @@ -566,11 +566,15 @@ def test_main(self): assert self.req.status_code == 200 time.sleep(12) - runtime_metrics = [metric for _, metric in interfaces.agent.get_metrics(request=self.req) if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")] + runtime_metrics = [ + metric + for _, metric in interfaces.agent.get_metrics() + if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.") + ] assert len(runtime_metrics) > 0 for metric in runtime_metrics: - tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"] } + tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"]} assert tags.get("lang") in runtime_metrics_langs or tags.get("lang") is None # Test that Unified Service Tags are added to the runtime metrics @@ -596,11 +600,15 @@ def test_main(self): assert self.req.status_code == 200 time.sleep(12) - runtime_metrics = [metric for _, metric in interfaces.agent.get_metrics(request=self.req) if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")] + runtime_metrics = [ + metric + for _, metric in interfaces.agent.get_metrics() + if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.") + ] assert len(runtime_metrics) > 0 for metric in runtime_metrics: - tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"] } + tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"]} assert "runtime-id" in tags diff --git a/utils/interfaces/_agent.py b/utils/interfaces/_agent.py index 6eabf540b19..9e53e9951ce 100644 --- a/utils/interfaces/_agent.py +++ b/utils/interfaces/_agent.py @@ -143,7 +143,7 @@ def get_spans(self, request=None): def get_spans_list(self, request): return [span for _, span in self.get_spans(request)] - def get_metrics(self, request=None): + def get_metrics(self): """Attempts to fetch the spans the agent will submit to the backend. When a valid request is given, then we filter the spans to the ones sampled From 0d413628518ee5d8f2ec9a138a9619968d7d89cb Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Mon, 27 Jan 2025 10:41:59 -0800 Subject: [PATCH 3/7] Fix for Java: Add environment variable to start sending DogstatsD immediately --- utils/_context/_scenarios/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index a64e87e27bb..0baa04683df 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -783,6 +783,7 @@ class _Scenarios: runtime_metrics_enabled = EndToEndScenario( "RUNTIME_METRICS_ENABLED", + weblog_env={"DD_DOGSTATSD_START_DELAY": "0"}, runtime_metrics_enabled=True, use_proxy_for_weblog=False, doc="Test runtime metrics", From 64b7924fc179eba0155543d5491cc5dd86146d50 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Tue, 28 Jan 2025 16:03:57 -0800 Subject: [PATCH 4/7] Fix for Java weblog applications: - Add Java weblog test skips - spring-boot-openliberty: Remove DD_JMXFETCH_ENABLED=false - spring-boot-wildfly: Set DD_APP_CUSTOMLOGMANAGER=true so that we can simultaneously enable JMXFetch and also let Wildfly set up its own java.util.logging backend. This allows the app server to succeed and the container to run, though it fails the tests. --- manifests/java.yml | 13 ++++++++++--- .../docker/java/spring-boot-openliberty.Dockerfile | 1 - .../docker/java/spring-boot-wildfly.Dockerfile | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/manifests/java.yml b/manifests/java.yml index 6e36e060abc..8c696aa3601 100644 --- a/manifests/java.yml +++ b/manifests/java.yml @@ -1711,9 +1711,16 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Default: v1.39.0 Test_Config_ObfuscationQueryStringRegexp_Empty: v1.39.0 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for java runtime metrics) - Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for java runtime metrics) - Test_Config_RuntimeMetrics_Enabled: v0.64.0 - Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: v0.64.0 + Test_Config_RuntimeMetrics_Enabled: + '*': v0.64.0 + spring-boot-3-native: missing_feature (GraalVM. Tracing support only) + spring-boot-openliberty: incomplete_test_app (needs investigation to understand why test is failing) + spring-boot-wildfly: incomplete_test_app (needs investigation to understand why test is failing) + Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: + '*': v0.64.0 + spring-boot-3-native: missing_feature (GraalVM. Tracing support only) + spring-boot-openliberty: incomplete_test_app (needs investigation to understand why test is failing) + spring-boot-wildfly: incomplete_test_app (needs investigation to understand why test is failing) Test_Config_UnifiedServiceTagging_CustomService: v1.39.0 Test_Config_UnifiedServiceTagging_Default: v1.39.0 test_data_integrity.py: diff --git a/utils/build/docker/java/spring-boot-openliberty.Dockerfile b/utils/build/docker/java/spring-boot-openliberty.Dockerfile index e974cf91975..849b770986f 100644 --- a/utils/build/docker/java/spring-boot-openliberty.Dockerfile +++ b/utils/build/docker/java/spring-boot-openliberty.Dockerfile @@ -22,7 +22,6 @@ COPY --from=build /binaries/SYSTEM_TESTS_LIBRARY_VERSION SYSTEM_TESTS_LIBRARY_VE COPY --from=build /app/target/myproject-0.0.1-SNAPSHOT.jar /app/app.jar COPY --from=build /dd-tracer/dd-java-agent.jar . -ENV DD_JMXFETCH_ENABLED=false ENV DD_TRACE_HEADER_TAGS='user-agent:http.request.headers.user-agent' # FIXME: Fails on APPSEC_BLOCKING, see APPSEC-51405 # ENV DD_TRACE_INTERNAL_EXIT_ON_FAILURE=true diff --git a/utils/build/docker/java/spring-boot-wildfly.Dockerfile b/utils/build/docker/java/spring-boot-wildfly.Dockerfile index 87947abdebc..cca2d0f347c 100644 --- a/utils/build/docker/java/spring-boot-wildfly.Dockerfile +++ b/utils/build/docker/java/spring-boot-wildfly.Dockerfile @@ -26,6 +26,7 @@ COPY --from=build /dd-tracer/dd-java-agent.jar . COPY ./utils/build/docker/java/app.sh /app/app.sh RUN chmod +x /app/app.sh +ENV DD_APP_CUSTOMLOGMANAGER=true ENV DD_TRACE_HEADER_TAGS='user-agent:http.request.headers.user-agent' ENV DD_TRACE_INTERNAL_EXIT_ON_FAILURE=true ENV APP_EXTRA_ARGS="-Djboss.http.port=7777 -b=0.0.0.0" From d69f9df45c442e2bcb816d681249782957f7ec61 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Wed, 29 Jan 2025 10:38:14 -0800 Subject: [PATCH 5/7] Fix up the documentation for AgentInterfaceValidator.get_metrics --- utils/interfaces/_agent.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utils/interfaces/_agent.py b/utils/interfaces/_agent.py index 9e53e9951ce..a5b536c46b8 100644 --- a/utils/interfaces/_agent.py +++ b/utils/interfaces/_agent.py @@ -144,11 +144,7 @@ def get_spans_list(self, request): return [span for _, span in self.get_spans(request)] def get_metrics(self): - """Attempts to fetch the spans the agent will submit to the backend. - - When a valid request is given, then we filter the spans to the ones sampled - during that request's execution, and only return those. - """ + """Attempts to fetch the metrics the agent will submit to the backend.""" for data in self.get_data(path_filters="/api/v2/series"): if "series" not in data["request"]["content"]: From 8b68daf783287361d3f2e996fd11df4068ed5592 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Wed, 29 Jan 2025 12:19:20 -0800 Subject: [PATCH 6/7] Small cleanup --- manifests/python.yml | 1 - utils/_context/_scenarios/__init__.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/python.yml b/manifests/python.yml index acdd922d88b..63e6212a6cd 100644 --- a/manifests/python.yml +++ b/manifests/python.yml @@ -894,7 +894,6 @@ tests/: Test_Config_ObfuscationQueryStringRegexp_Configured: v2.0.0 Test_Config_ObfuscationQueryStringRegexp_Empty: v2.15.0 Test_Config_RuntimeMetrics_Default: incomplete_test_app (test needs to account for python runtime metrics) - Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (test needs to account for python runtime metrics) Test_Config_RuntimeMetrics_Enabled: incomplete_test_app (Python seems to send sketches instead of gauges/counters) Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: missing_feature Test_Config_UnifiedServiceTagging_CustomService: v2.0.0 diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index 0baa04683df..392b92c6b66 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -785,6 +785,9 @@ class _Scenarios: "RUNTIME_METRICS_ENABLED", weblog_env={"DD_DOGSTATSD_START_DELAY": "0"}, runtime_metrics_enabled=True, + # Disable the proxy in between weblog and the agent so that we can send metrics (via UDP) to the agent. + # The mitmproxy can only proxy UDP traffic by doing a host-wide transparent proxy, but we currently + # via specific ports. As a result, with the proxy enabled all UDP traffic is being dropped. use_proxy_for_weblog=False, doc="Test runtime metrics", ) From 0391d54d2a34feb19afc0b585b011e877f2d5a58 Mon Sep 17 00:00:00 2001 From: Zach Montoya Date: Thu, 30 Jan 2025 14:20:58 -0800 Subject: [PATCH 7/7] PR Feedback: Move the time.sleep() call to the setup_ methods and document the reason for the DD_DOGSTATSD_START_DELAY=0 configuration. --- tests/test_config_consistency.py | 8 ++++++-- utils/_context/_scenarios/__init__.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_config_consistency.py b/tests/test_config_consistency.py index 1d7a21c3d17..47ea9cfd888 100644 --- a/tests/test_config_consistency.py +++ b/tests/test_config_consistency.py @@ -562,10 +562,12 @@ class Test_Config_RuntimeMetrics_Enabled: def setup_main(self): self.req = weblog.get("/") + # Wait for 10s to allow the tracer to send runtime metrics on the default 10s interval + time.sleep(10) + def test_main(self): assert self.req.status_code == 200 - time.sleep(12) runtime_metrics = [ metric for _, metric in interfaces.agent.get_metrics() @@ -596,10 +598,12 @@ class Test_Config_RuntimeMetrics_Enabled_WithRuntimeId: def setup_main(self): self.req = weblog.get("/") + # Wait for 10s to allow the tracer to send runtime metrics on the default 10s interval + time.sleep(10) + def test_main(self): assert self.req.status_code == 200 - time.sleep(12) runtime_metrics = [ metric for _, metric in interfaces.agent.get_metrics() diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index 392b92c6b66..07d63ea33b2 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -783,6 +783,9 @@ class _Scenarios: runtime_metrics_enabled = EndToEndScenario( "RUNTIME_METRICS_ENABLED", + # Add environment variable DD_DOGSTATSD_START_DELAY=0 to avoid the default 30s startup delay in the Java tracer. + # That delay is used in production to reduce the impact on startup and other side-effects on various application + # servers. These considerations do not apply to the system-tests environment so we can reduce it to 0s. weblog_env={"DD_DOGSTATSD_START_DELAY": "0"}, runtime_metrics_enabled=True, # Disable the proxy in between weblog and the agent so that we can send metrics (via UDP) to the agent.