feat(otel): system-tests for DB (postgres) OpenTelemetry semantic conventions#7166
Draft
khanayan123 wants to merge 4 commits into
Draft
Conversation
Contributor
|
|
|
…vention tests The database counterpart to the HTTP OTel-semantics work. Adds an OTEL_SEMANTICS_DB scenario (postgres container + DD_TRACE_OTEL_SEMANTICS_ENABLED=true) and tests/integrations/test_otel_db_semantics.py asserting that postgres SQL spans emit the OpenTelemetry database semantic-convention attribute names instead of the Datadog ones: db.type/db.system -> db.system.name (= "postgresql") db.name/db.instance -> db.namespace db.operation -> db.operation.name db.statement -> db.query.text out.host -> server.address Reuses the proven BaseDbIntegrationsTestClass / /db endpoint / sql-span pattern. No tracer implements DB OTel semantics yet (DD_TRACE_OTEL_SEMANTICS_ENABLED currently covers HTTP only — confirmed in dd-trace-dotnet#8791/java#11652/js#8933), so the tests are gated missing_feature for every language. They encode the target contract and activate per-tracer as DB support lands; not e2e-verifiable until then. Open question (asserted to the stable spec for now): the stable spec name is `db.system.name`, but the experimental/Datadog name is `db.system` — flagged for the tracer teams. Spec: https://opentelemetry.io/docs/specs/semconv/db/database-spans/ Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lection.name, server.port) Add the two remaining renamed-attribute tests so the DB suite covers the full set of Datadog->OTel renames per the spec: db.sql.table -> db.collection.name out.port -> server.port (validated as int when present) The suite now has 7 rename tests (db.system.name, db.namespace, db.operation.name, db.query.text, db.collection.name, server.address, server.port). Only rename tests are included because the scenario is gated missing_feature everywhere (no tracer implements DB OTel yet) — unchanged/shared attributes like span.kind and error.type would xpass, so they belong in the OTLP-typed variant / when-active coverage instead. ruff + Manifest.validate() + meta-tests green; 7 tests collect under OTEL_SEMANTICS_DB. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…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>
dd-trace-js#8961 (stacked on the HTTP semantics PR) implements DB OTel semantic conventions, so Test_PostgresOtelSemantics now passes for nodejs. Drop the missing_feature gate. Verified by replay against the tracer build: OTEL_SEMANTICS_DB 9 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
13dd2ee to
f91efe9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The database extension of the HTTP OTel-semantics work (#7139) — system-tests asserting that postgres SQL spans honor the OpenTelemetry database semantic conventions when
DD_TRACE_OTEL_SEMANTICS_ENABLED=true.Spec: https://opentelemetry.io/docs/specs/semconv/db/database-spans/
Changes
OTEL_SEMANTICS_DBscenario — postgres container +DD_TRACE_OTEL_SEMANTICS_ENABLED=true.tests/integrations/test_otel_db_semantics.py—Test_PostgresOtelSemantics, reusing the provenBaseDbIntegrationsTestClass//db/sql-span pattern. 7 tests covering every Datadog→OTel rename in the spec.Renamed-attribute coverage (Datadog → OTel)
db.type/db.systemdb.system.name("postgresql")db.name/db.instancedb.namespace(database)db.operationdb.operation.namedb.statementdb.query.textdb.sql.tabledb.collection.nameout.hostserver.addressout.portserver.port(int)Each test asserts the OTel name is present/correct and the legacy Datadog name is absent (mutually exclusive, as for HTTP).
Why rename-tests only
The scenario is gated
missing_featureeverywhere (no tracer implements DB OTel yet), so a test must fail when the feature is off to xfail correctly. Rename tests do (the OTel name is absent / the legacy name is present). Unchanged/shared attributes (span.kind=client,error.type) would pass regardless → xpass, so they aren't in this gated class; they belong to the OTLP-typed variant / when-active coverage.Status: forward-looking spec contract
No tracer implements DB OTel semantics yet —
DD_TRACE_OTEL_SEMANTICS_ENABLEDcovers HTTP only (confirmed in dd-trace-dotnet#8791 / dd-trace-java#11652 / dd-trace-js#8933; dotnet has DB test scaffolding but its production flag gates HTTP only). So the tests encode the target contract, gatedmissing_featurefor every language, and activate per-tracer as DB support lands. Not e2e-verified until then (unlike the HTTP work, validated against dd-trace-js#8933).Open question for the tracer teams
db.system.name(stable spec) vsdb.system(experimental/Datadog; existing DD tests already assertdb.system == "postgresql"). Asserted the stable name per the authoritative-harness principle, withdb.systemasserted absent — to be reconciled with whatever the tracers emit.Follow-ups
OTEL_SEMANTICS_OTLP) — asserts the integer types (server.port,db.response.status_code,db.operation.batch.size) the agent protocol can't represent, plus the unchanged/shared attributes.db.query.textsanitization (literals →?),db.query.summary,network.peer.*, and the DB span-name rule ({db.operation.name} {target}, low-cardinality).Verification
ruffclean;Manifest.validate()(format + key-order + nodeid existence) passes;test_the_testmeta-tests pass; 7 tests collect underOTEL_SEMANTICS_DB.🤖 Generated with Claude Code