Skip to content

Commit 13dd2ee

Browse files
khanayan123claude
andcommitted
test(otel): fix server.port DB test to be a proper rename test (meta-or-metrics)
Running OTEL_SEMANTICS_DB against dd-trace-js master revealed test_server_port xpassed: the previous version only checked `out.port` absent, but dd-trace-js puts the port in `metrics[network.destination.port]` (=5433), so "out.port absent" was trivially true and the test passed even though no OTel rename occurred. Fix: require server.port present (the postgres port is non-default, so the spec expects it), read it from meta OR metrics, and assert both legacy port names (out.port, network.destination.port) are absent. Now all 7 rename tests xfail correctly when the feature is unimplemented. Finding: dd-trace-js master does NOT implement OTel DB semantics — its postgres SQL span emits Datadog names (db.name, db.type=postgres, out.host, network.destination.port) and none of the OTel names. Confirms the suite's all-gated (missing_feature) status. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ec9bece commit 13dd2ee

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tests/integrations/test_otel_db_semantics.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,17 @@ def test_server_address(self):
8585
assert "out.host" not in meta, "legacy out.host must be absent in OTel mode"
8686

8787
def test_server_port(self):
88-
"""``out.port`` becomes ``server.port`` (validated as an int when present)."""
89-
for db_operation, meta in self._tracer_span_metas():
90-
assert "out.port" not in meta, f"legacy out.port must be absent in OTel mode (failing for {db_operation})"
91-
if "server.port" in meta:
92-
_ = int(meta["server.port"]) # must be int-parseable when present
88+
"""``out.port`` / ``network.destination.port`` become ``server.port``.
89+
90+
The postgres port is non-default, so per the spec server.port is expected. Numeric values
91+
may live in ``metrics`` rather than ``meta`` depending on the tracer, so check both.
92+
"""
93+
for db_operation, request in self.get_requests(excluded_operations=("select_error",)):
94+
span = self.get_span_from_tracer(request)
95+
meta, metrics = span.meta, span.metrics
96+
port = meta.get("server.port", metrics.get("server.port"))
97+
assert port is not None, f"server.port expected (non-default port), failing for {db_operation}"
98+
_ = int(port)
99+
for legacy in ("out.port", "network.destination.port"):
100+
assert legacy not in meta, f"legacy {legacy} must be absent in meta in OTel mode ({db_operation})"
101+
assert legacy not in metrics, f"legacy {legacy} must be absent in metrics in OTel mode ({db_operation})"

0 commit comments

Comments
 (0)