Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Khanayan123/add consistent config system tests #3745

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b0eea10
save changes
khanayan123 Dec 25, 2024
264a755
Add runtime metrics tests
cbeauchesne Dec 13, 2024
252ad46
Add basic deserialization
cbeauchesne Dec 19, 2024
c1d9118
add runtime metrics test
khanayan123 Dec 25, 2024
f53f99c
push changes
khanayan123 Dec 28, 2024
60d2872
fix redordering
khanayan123 Dec 28, 2024
72fd00a
update
khanayan123 Jan 2, 2025
b792106
update
khanayan123 Jan 2, 2025
41dd15a
update
khanayan123 Jan 2, 2025
efa3ef3
update php manifest
khanayan123 Jan 2, 2025
e871399
fix redordering
khanayan123 Jan 2, 2025
d963739
try
khanayan123 Jan 2, 2025
a4d445f
update test
khanayan123 Jan 2, 2025
6cf3b31
update manifest file
khanayan123 Jan 2, 2025
918fbbb
update logger
khanayan123 Jan 2, 2025
bb91710
lint
khanayan123 Jan 2, 2025
78b9e7b
update test
khanayan123 Jan 2, 2025
e954a94
enable 128 bit trace id tests
khanayan123 Jan 3, 2025
6a2057e
update
khanayan123 Jan 6, 2025
bf111d5
add new endpoint logs
khanayan123 Jan 6, 2025
dd4a9c6
format
khanayan123 Jan 6, 2025
3afd035
fix
khanayan123 Jan 6, 2025
7f51151
update implemented version
khanayan123 Jan 6, 2025
f5b4d41
update version
khanayan123 Jan 6, 2025
59c1a37
address feedback
khanayan123 Jan 9, 2025
3429244
refactor
khanayan123 Jan 9, 2025
9f484c5
run lint
khanayan123 Jan 9, 2025
54b89be
update annotations
khanayan123 Jan 9, 2025
2d42831
add jira ticket number
khanayan123 Jan 10, 2025
69a1e60
break apart test_w3c_128_bit_propagation_tid_in_chunk_root test
khanayan123 Jan 10, 2025
0eb65dd
run format
khanayan123 Jan 10, 2025
17b45bd
skip ruby
khanayan123 Jan 10, 2025
6945a62
address feedback
khanayan123 Jan 10, 2025
3d14959
run format
khanayan123 Jan 10, 2025
9ed1223
simplify
khanayan123 Jan 10, 2025
4c75e27
format
khanayan123 Jan 10, 2025
7d68776
add ipv6 tests, wait for generator
khanayan123 Jan 10, 2025
d2e0312
update node test app
khanayan123 Jan 10, 2025
75e4d32
run formatter
khanayan123 Jan 10, 2025
bda76a0
update to skip test for missing_features
khanayan123 Jan 10, 2025
9dfa2a3
run formatter
khanayan123 Jan 10, 2025
6e8f305
fix test app
khanayan123 Jan 10, 2025
c363d24
fix testapp
khanayan123 Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/weblog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,14 @@ Expected query parameters:
This endpoint loads a module/package in applicable languages. It's mainly used for telemetry tests to verify that
the `dependencies-loaded` event is appropriately triggered.

### GET /log/library

This endpoint facilitates the loading of a logging library and logs a specified message. It is primarily designed for testing log injection functionality

The following query parameters are optional:
- `msg`: Specifies the message to be logged. If not provided, the default message "msg" will be logged.
- `level`: Specifies the log level to be used. If not provided, the default log level is "info".

### GET /e2e_single_span

This endpoint will create two spans, a parent span (which is a root-span), and a child span.
Expand Down
6 changes: 6 additions & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,14 @@ tests/:
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
Test_Config_IntegrationEnabled_False: missing_feature
Test_Config_IntegrationEnabled_True: missing_feature
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: missing_feature
Test_Config_ObfuscationQueryStringRegexp_Empty: missing_feature
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: missing_feature
Test_Config_UnifiedServiceTagging_Default: missing_feature
test_distributed.py:
Expand Down
6 changes: 6 additions & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,14 @@ tests/:
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: v3.5.0
Test_Config_IntegrationEnabled_False: v3.5.0
Test_Config_IntegrationEnabled_True: v3.5.0
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: v3.4.1
Test_Config_ObfuscationQueryStringRegexp_Empty: v3.4.1
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v3.3.0
Test_Config_UnifiedServiceTagging_Default: v3.3.0
test_data_integrity.py:
Expand Down
6 changes: 6 additions & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,14 @@ tests/:
uds-echo: missing_feature
Test_Config_IntegrationEnabled_False: irrelevant (not applicable to Go because of how they do auto instrumentation)
Test_Config_IntegrationEnabled_True: irrelevant (not applicable to Go because of how they do auto instrumentation)
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: v1.67.0
Test_Config_ObfuscationQueryStringRegexp_Empty: v1.67.0
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v1.67.0
Test_Config_UnifiedServiceTagging_Default: v1.67.0
test_data_integrity.py:
Expand Down
8 changes: 8 additions & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1648,8 +1648,16 @@ tests/:
Test_Config_IntegrationEnabled_True:
'*': irrelevant (kafka endpoints are not implemented)
spring-boot: v1.42.0
Test_Config_IntegrationEnabled_False: irrelevant (not applicable to Go because of how they do auto instrumentation)
Test_Config_IntegrationEnabled_True: irrelevant (not applicable to Go because of how they do auto instrumentation)
simon-id marked this conversation as resolved.
Show resolved Hide resolved
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: v1.39.0
Test_Config_ObfuscationQueryStringRegexp_Empty: v1.39.0
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v1.39.0
Test_Config_UnifiedServiceTagging_Default: v1.39.0
test_data_integrity.py:
Expand Down
21 changes: 19 additions & 2 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ tests/:
test_k8s_manual_inject.py:
TestAdmisionControllerProfiling: *ref_5_22_0
parametric/:
test_128_bit_traceids.py:
Test_128_Bit_Traceids: *ref_3_0_0
test_config_consistency.py:
Test_Config_Dogstatsd: *ref_5_29_0
Test_Config_RateLimit: *ref_5_25_0
Expand Down Expand Up @@ -849,13 +851,28 @@ tests/:
Test_Config_IntegrationEnabled_False:
'*': *ref_5_25_0
express4-typescript: irrelevant
nextjs: irrelevant # nextjs is not related with kafka
nextjs: irrelevant
Test_Config_IntegrationEnabled_True:
'*': *ref_5_25_0
express4-typescript: irrelevant
nextjs: irrelevant # nextjs is not related with kafka
nextjs: irrelevant
Test_Config_LogInjection_128Bit_TradeId_Default: missing_feature
Test_Config_LogInjection_128Bit_TradeId_Disabled:
'*': *ref_3_15_0
express4-typescript: irrelevant
nextjs: irrelevant
Test_Config_LogInjection_Default:
'*': *ref_3_0_0
express4-typescript: irrelevant
nextjs: irrelevant
Test_Config_LogInjection_Enabled:
'*': *ref_3_0_0
express4-typescript: irrelevant
nextjs: irrelevant
simon-id marked this conversation as resolved.
Show resolved Hide resolved
Test_Config_ObfuscationQueryStringRegexp_Configured: *ref_3_0_0
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_UnifiedServiceTagging_CustomService: *ref_5_25_0
Test_Config_UnifiedServiceTagging_Default: *ref_5_25_0
test_distributed.py:
Expand Down
6 changes: 6 additions & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,14 @@ tests/:
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
Test_Config_IntegrationEnabled_False: v1.4.0
Test_Config_IntegrationEnabled_True: v1.4.0
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: v1.5.0
Test_Config_ObfuscationQueryStringRegexp_Empty: v1.5.0
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v1.4.0
Test_Config_UnifiedServiceTagging_Default: v1.4.0
test_distributed.py:
Expand Down
6 changes: 6 additions & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,14 @@ tests/:
Test_Config_IntegrationEnabled_True:
'*': irrelevant (kafka endpoint is not implemented)
flask-poc: v2.0.0
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: v2.0.0
Test_Config_ObfuscationQueryStringRegexp_Empty: v2.15.0
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v2.0.0
Test_Config_UnifiedServiceTagging_Default: v2.0.0
test_data_integrity.py:
Expand Down
6 changes: 6 additions & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,14 @@ tests/:
Test_Config_IntegrationEnabled_True:
'*': irrelevant (endpoint not implemented)
rails70: v2.0.0
Test_Config_LogInjection_128Bit_TradeId_Default: incomplete_test_app
Test_Config_LogInjection_128Bit_TradeId_Disabled: incomplete_test_app
Test_Config_LogInjection_Default: incomplete_test_app
Test_Config_LogInjection_Enabled: incomplete_test_app
Test_Config_ObfuscationQueryStringRegexp_Configured: missing_feature
Test_Config_ObfuscationQueryStringRegexp_Empty: missing_feature (environment variable is not supported)
Test_Config_RuntimeMetrics_Default: incomplete_test_app
Test_Config_RuntimeMetrics_Enabled: incomplete_test_app
Test_Config_UnifiedServiceTagging_CustomService: v2.0.0
Test_Config_UnifiedServiceTagging_Default: v2.0.0
test_distributed.py:
Expand Down
2 changes: 0 additions & 2 deletions tests/parametric/test_128_bit_traceids.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def test_datadog_128_bit_generation_enabled(self, test_agent, test_library):

@missing_feature(context.library == "golang", reason="not implemented")
@missing_feature(context.library < "[email protected]", reason="Implemented in 1.24.0")
@missing_feature(context.library == "nodejs", reason="not implemented")
@missing_feature(context.library == "ruby", reason="not implemented")
@pytest.mark.parametrize("library_env", [{"DD_TRACE_PROPAGATION_STYLE": "Datadog"}])
def test_datadog_128_bit_generation_enabled_by_default(self, test_agent, test_library):
simon-id marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -409,7 +408,6 @@ def test_w3c_128_bit_propagation_tid_consistent(self, test_agent, test_library):
assert propagation_error is None

@missing_feature(context.library == "ruby", reason="not implemented")
@missing_feature(context.library == "nodejs", reason="not implemented")
@missing_feature(context.library == "java", reason="not implemented")
@pytest.mark.parametrize(
"library_env",
Expand Down
69 changes: 69 additions & 0 deletions tests/parametric/test_trace_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,75 @@ def test_trace_sampled_by_trace_sampling_rule_glob_match(self, test_agent, test_
assert span["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert span["metrics"].get(SAMPLING_RULE_PRIORITY_RATE) == 1.0

@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_SAMPLE_RATE": 0,
"DD_TRACE_SAMPLING_RULES_FORMAT": "glob",
"DD_TRACE_SAMPLING_RULES": json.dumps(
[
{"name": "wEb.rEquEst", "sample_rate": 1},
]
),
},
{
"DD_TRACE_SAMPLE_RATE": 0,
"DD_TRACE_SAMPLING_RULES": json.dumps([{"service": "wEbSerVer", "sample_rate": 1}]),
},
{
"DD_TRACE_SAMPLE_RATE": 0,
"DD_TRACE_SAMPLING_RULES_FORMAT": "glob",
"DD_TRACE_SAMPLING_RULES": json.dumps([{"resource": "/rAnDom", "sample_rate": 1}]),
},
{
"DD_TRACE_SAMPLE_RATE": 0,
"DD_TRACE_SAMPLING_RULES_FORMAT": "glob",
"DD_TRACE_SAMPLING_RULES": json.dumps([{"tags": {"key": "vAlUe"}, "sample_rate": 1}]),
},
],
)
@missing_feature(library="cpp", reason="Not implemented")
@missing_feature(library="nodejs", reason="Not implemented")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a "bug"?

def test_field_case_insensitivity(self, test_agent, test_library):
"""Test span sampling tags are added when a rule with glob patterns with special characters * and ? match"""
with test_library:
with test_library.dd_start_span(
name="web.request", service="webserver", resource="/random", tags=[("key", "value")]
) as span:
pass

span = find_only_span(test_agent.wait_for_num_traces(1))

assert span["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert span["metrics"].get(SAMPLING_RULE_PRIORITY_RATE) == 1.0

@pytest.mark.parametrize(
"library_env",
[
{
"DD_TRACE_SAMPLE_RATE": 0,
"DD_TRACE_SAMPLING_RULES": json.dumps(
[
{"name": "wEb.*", "sample_rate": 1},
]
),
}
],
)
def test_trace_sampling_rules_format_not_needed(self, test_agent, test_library):
"""Glob should work by default without specifying the format"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertions/spans in this test look identical to test_field_case_insensitivity. S
hould we add the library_env in this test to test_field_case_insensitivity parameterized test? This way we have one test with 5 scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could just remove it from all the tests since I believe no language currently requires the glob environment variable

with test_library:
with test_library.dd_start_span(
name="web.request", service="webserver", resource="/random", tags=[("key", "value")]
) as span:
pass

span = find_only_span(test_agent.wait_for_num_traces(1))

assert span["metrics"].get(SAMPLING_PRIORITY_KEY) == 2
assert span["metrics"].get(SAMPLING_RULE_PRIORITY_RATE) == 1.0

@pytest.mark.parametrize(
"library_env",
[
Expand Down
90 changes: 90 additions & 0 deletions tests/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
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"}


@scenarios.default
@features.tracing_configuration_consistency
Expand Down Expand Up @@ -415,3 +419,89 @@ def test_integration_enabled_true(self):
assert list(
filter(lambda span: "kafka.produce" in span.get("name"), spans)
), f"No kafka.produce span found in trace: {spans}"


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_LogInjection_Enabled:
"""Verify behavior of integrations automatic spans"""

def setup_log_injection_enabled(self):
self.message = "msg"
self.r = weblog.get("/log/library", params={"msg": self.message})

def test_log_injection_enabled(self):
assert self.r.status_code == 200
pattern = rf'"dd":\{{"trace_id":"[^"]+","span_id":"\d+","service":"[^"]+","version":"[^"]+","env":"[^"]+"\}},"msg":"{self.message}"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this pattern more permissive? If there's whitespace between the entries then the pattern will fail to match. Also it requires log correlation fields to be wrapped in curly brackets and the message to printed after a comma. Also the values may not always be wrapped in quotes.

This is an example of a log message generated by the python tracer:

Python docs: https://docs.datadoghq.com/tracing/other_telemetry/connect_logs_and_traces/python/

import ddtrace
import logging

FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] '
          '[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] '
          '- %(message)s')
logging.basicConfig(format=FORMAT)

log = logging.getLogger(__name__)

with ddtrace.tracer.trace("test"):
    log.error("test")

Output:
2025-01-06 17:21:00,421 ERROR [__main__] [reproduction.py:20] [dd.service=Downloads dd.env= dd.version= dd.trace_id=677c574c000000001679fe710d0f33ba dd.span_id=10973182204132464872] - test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the other way to solve this issue is to have weblog apps send json formatted logs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make parsing easier

stdout.assert_presence(pattern)


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault_2
@features.tracing_configuration_consistency
class Test_Config_LogInjection_Default:
def setup_log_injection_default(self):
self.message = "msg"
self.r = weblog.get("/log/library", params={"msg": self.message})

def test_log_injection_default(self):
assert self.r.status_code == 200
pattern = r'"dd":\{"trace_id":"[^"]+","span_id":"\d+","service":"[^"]+","version":"[^"]+","env":"[^"]+"\},"msg":"^"]+"'
stdout.assert_absence(pattern)


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_LogInjection_128Bit_TradeId_Default:
"""Verify 128 bit traceid are enabled in log injection by default"""

def setup_log_injection_128bit_traceid_default(self):
self.message = "msg"
self.r = weblog.get("/log/library", params={"msg": self.message})

def test_log_injection_128bit_traceid_default(self):
assert self.r.status_code == 200
pattern = r'"dd":\{"trace_id":"[0-9a-f]{32}"'
stdout.assert_presence(pattern)


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault_2
@features.tracing_configuration_consistency
class Test_Config_LogInjection_128Bit_TradeId_Disabled:
def setup_log_injection_128bit_traceid_disabled(self):
self.message = "msg"
self.r = weblog.get("/log/library", params={"msg": self.message})

def test_log_injection_128bit_traceid_disabled(self):
assert self.r.status_code == 200
pattern = r'"dd":\{"trace_id":"\d+"'
stdout.assert_presence(pattern)


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.runtime_metrics_enabled
@features.tracing_configuration_consistency
class Test_Config_RuntimeMetrics_Enabled:
# This test verifies runtime metrics from the Node.js tracer. It will need to evolve to support assertion on metrics from other tracers
def test_config_runtimemetrics_enabled(self):
data = list(interfaces.library.get_data("/dogstatsd/v2/proxy"))[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a race condition here. At least in .NET we submit runtime metrics every 10s, so we'll need to add some sort of wait or configure the delay in a similar fashion for both the Enabled case and the Default case

lines = data["request"]["content"].split("\n")
metric_found = False
for line in lines:
if runtime_metrics["nodejs"] in line:
metric_found = True
break
assert metric_found, f'The metric {runtime_metrics["nodejs"]} was not found in any line'


@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_RuntimeMetrics_Default:
# test that by default runtime metrics are disabled
def test_config_runtimemetrics_default(self):
data = list(interfaces.library.get_data("/dogstatsd/v2/proxy"))
assert len(data) == 0
9 changes: 9 additions & 0 deletions utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ class _Scenarios:
"DD_TRACE_KAFKAJS_ENABLED": "false", # In Node the integration is kafkajs.
"DD_TRACE_PDO_ENABLED": "false", # Use PDO for PHP,
"DD_TRACE_PROPAGATION_STYLE_EXTRACT": "tracecontext,datadog,b3multi",
"DD_LOGS_INJECTION": "true",
},
appsec_enabled=False, # disable ASM to test non asm client ip tagging
iast_enabled=False,
Expand All @@ -508,6 +509,8 @@ class _Scenarios:
"DD_TRACE_CLIENT_IP_HEADER": "custom-ip-header",
"DD_TRACE_CLIENT_IP_ENABLED": "true",
"DD_TRACE_PROPAGATION_STYLE_EXTRACT": "datadog,tracecontext,b3multi",
"DD_LOGS_INJECTION": "true",
"DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED": "false",
},
include_kafka=True,
include_postgres_db=True,
Expand Down Expand Up @@ -781,6 +784,12 @@ class _Scenarios:
external_processing = ExternalProcessingScenario("EXTERNAL_PROCESSING")
ipv6 = IPV6Scenario("IPV6")

runtime_metrics_enabled = EndToEndScenario(
"RUNTIME_METRICS_ENABLED",
runtime_metrics_enabled=True,
doc="Test runtime metrics",
)


scenarios = _Scenarios()

Expand Down
Loading
Loading