Skip to content

Commit c993a8e

Browse files
authored
Enable NodeJS client side stats tests (#7252)
1 parent fff1983 commit c993a8e

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

manifests/nodejs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ refs:
9999
- &ref_5_107_0 '>=5.107.0'
100100
- &ref_5_109_0 '>=5.109.0'
101101
- &ref_5_110_0 '>=5.110.0'
102+
- &ref_5_111_0 '>=5.111.0'
102103
- &ref_6_0_0 '>=6.0.0-pre'
103104
manifest:
104105
tests/ai_guard/test_ai_guard_sdk.py::Test_AIGuardEvent_Tag:
@@ -2193,8 +2194,7 @@ manifest:
21932194
tests/parametric/test_otel_span_methods.py::Test_Otel_Span_Methods::test_otel_start_span: missing_feature (New operation name mapping not yet implemented)
21942195
tests/parametric/test_otel_span_with_baggage.py::Test_Otel_Span_With_Baggage: *ref_5_32_0
21952196
tests/parametric/test_otel_tracer.py::Test_Otel_Tracer::test_otel_force_flush: missing_feature (Not implemented)
2196-
tests/parametric/test_otlp_trace_metrics.py: missing_feature
2197-
tests/parametric/test_otlp_trace_metrics.py::Test_FR02_Mutual_Exclusion::test_fr02_4_native_stats_no_otlp: missing_feature (nodejs has not implemented native client-side /v0.6/stats computation)
2197+
tests/parametric/test_otlp_trace_metrics.py: *ref_5_111_0
21982198
tests/parametric/test_otlp_trace_metrics.py::Test_FR05_Sampling_Independence::test_fr05_1_metrics_computed_before_sampling: missing_feature (nodejs does not drop sampled-out traces when client-side stats are computed)
21992199
tests/parametric/test_otlp_trace_metrics.py::Test_FR06_Otel_Resource_Attributes::test_fr06_10_hostname: irrelevant (DD_HOSTNAME is only supported in Python)
22002200
tests/parametric/test_otlp_trace_metrics.py::Test_FR08_Datadog_Attributes::test_fr08_5_top_level_child_different_service: missing_feature (nodejs does not tag child spans with a different service than their parent as top-level)

tests/parametric/test_otlp_trace_metrics.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,40 @@ def test_fr08_8_process_tags(
11551155
f"Expected at least one datadog.<process-tag> resource attribute, got: {list(resource_attrs)}"
11561156
)
11571157

1158+
@pytest.mark.parametrize("library_env", [{**DEFAULT_ENVVARS}])
1159+
def test_fr08_9_top_level_not_mixed_with_measured(
1160+
self,
1161+
otlp_trace_metrics_library_env: dict[str, str], # noqa: ARG002
1162+
test_agent: TestAgentAPI,
1163+
test_library: APMLibrary,
1164+
):
1165+
"""A top-level and a non-top-level span with identical dimensions bucket separately.
1166+
1167+
The measured child (selected per FR04) shares every aggregation dimension with its top-level root,
1168+
yet the two must yield separate data points -- one datadog.span.top_level=true, one false -- rather
1169+
than being merged into a single bucket mislabeled false.
1170+
"""
1171+
with test_library as t:
1172+
with (
1173+
t.dd_start_span(name="web.request", service=SERVICE, typestr="web") as parent,
1174+
t.dd_start_span(name="web.request", service=SERVICE, typestr="web", parent_id=parent.span_id) as child,
1175+
):
1176+
child.set_metric(SPAN_MEASURED_KEY, 1)
1177+
t.dd_flush()
1178+
1179+
metrics = test_agent.wait_for_num_otlp_metrics(num=1)
1180+
points = [
1181+
dp
1182+
for dp in _duration_data_points(metrics)
1183+
if _data_point_attrs(dp).get("datadog.operation.name") == "web.request"
1184+
]
1185+
top_level_flags = {_data_point_attrs(dp).get("datadog.span.top_level") for dp in points}
1186+
assert top_level_flags == {True, False}, (
1187+
"Top-level and non-top-level measured spans sharing the same aggregation dimensions must bucket "
1188+
"separately, each keeping its datadog.span.top_level flag; expected both a true and a false data "
1189+
f"point, got: {[_data_point_attrs(dp) for dp in points]}"
1190+
)
1191+
11581192

11591193
@scenarios.parametric
11601194
@features.client_side_stats_supported

0 commit comments

Comments
 (0)