Skip to content

Db semantic conventions update - #48979

Open
Radhika Gupta (rads-1996) wants to merge 9 commits into
Azure:mainfrom
rads-1996:db-semantic-conventions-update
Open

Db semantic conventions update#48979
Radhika Gupta (rads-1996) wants to merge 9 commits into
Azure:mainfrom
rads-1996:db-semantic-conventions-update

Conversation

@rads-1996

Copy link
Copy Markdown
Member

Description

Fixes - #48958

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions Bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Sep 11, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Two moderate SQL Server compatibility issues remain unresolved.

Pull request overview

Updates Azure Monitor OpenTelemetry database semantic-convention handling while retaining deprecated attribute compatibility.

Changes:

  • Adds stable database attribute support for exporter and QuickPulse telemetry.
  • Updates namespace, target, and port resolution.
  • Adds regression tests and changelog documentation.
File summaries
File Summary
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_trace.py Adds stable database span conversion tests.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_types.py Adds stable QuickPulse database tests.
sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md Documents the semantic-convention update.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py Supports stable attributes; needs stable SQL Server default-port handling.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py Maps stable database attributes; needs stable SQL Server normalization.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_types.py Adds stable database mapping for QuickPulse.
Review details

Suppressed comments (2)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py:430

  • The stable db.system.name value for SQL Server is microsoft.sql_server, but this path only treats the deprecated mssql value as SQL via _is_sql_db. Stable SQL Server spans therefore fall through to data.type = db_system and are emitted as microsoft.sql_server, instead of preserving the existing SQL dependency type produced for legacy SQL Server spans. Normalize the stable alias as well.
                db_system = span.attributes.get(DB_SYSTEM_NAME) or span.attributes.get(SpanAttributes.DB_SYSTEM)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:167

  • The stable db.system.name value for SQL Server is microsoft.sql_server, but _get_default_port_db only recognizes the deprecated mssql value. A CLIENT span with the stable attribute, net.peer.name, and the default port 1433 will therefore be emitted with target=host:1433 instead of omitting the default port, unlike the legacy path. Add the stable value to the default-port mapping and cover this case.
                if port != _get_default_port_http(attributes) and port != _get_default_port_db(str(db_system_for_port)):
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Stable SQL Server normalization and server endpoint/default-port handling require fixes and regression coverage.

Review details

Suppressed comments (4)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py:430

  • The stable convention uses db.system.name="microsoft.sql_server", but the existing type mapping and _is_sql_db/DbSystemValues.MSSQL checks recognize only the legacy mssql value. A stable SQL Server span will therefore be exported with dependency type microsoft.sql_server instead of the existing SQL mapping. Normalize this stable value before the mapping or update the shared SQL-system handling, and add a regression test.
                db_system = span.attributes.get(DB_SYSTEM_NAME) or span.attributes.get(SpanAttributes.DB_SYSTEM)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:167

  • This new branch changes whether net.peer.port is included in the target for stable database spans, but the added tests only cover the system/query/namespace/operation fields and never exercise default versus non-default database ports. A stable PostgreSQL span with net.peer.port=5432 must not become host:5432, while a non-default port must remain visible; add regression cases for both so this changed target-formatting path is protected.
                db_system_for_port = attributes.get(db_attributes.DB_SYSTEM_NAME) or attributes.get(
                    SpanAttributes.DB_SYSTEM
                )
                if port != _get_default_port_http(attributes) and port != _get_default_port_db(str(db_system_for_port)):

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:167

  • Stable database client spans use server.address/server.port for the database endpoint, but this helper still derives the target only from net.peer.name/net.peer.ip and net.peer.port. A span with db.system.name plus server.address therefore loses the server host (and port) and falls back to only db.namespace/the system name in _get_target_for_db_dependency; read the stable server attributes here while retaining the deprecated peer fallback, and cover it in both exporter paths.
                # Honor both the new stable `db.system.name` and the deprecated `db.system`.
                db_system_for_port = attributes.get(db_attributes.DB_SYSTEM_NAME) or attributes.get(
                    SpanAttributes.DB_SYSTEM
                )
                if port != _get_default_port_http(attributes) and port != _get_default_port_db(str(db_system_for_port)):

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:167

  • The stable convention uses db.system.name="microsoft.sql_server", while _get_default_port_db recognizes only the legacy mssql value. Consequently a stable SQL Server span using the default port 1433 will be rendered with :1433 in its target instead of omitting the default port. Extend or normalize the database-port mapping for the stable value and cover this case in a test.
                db_system_for_port = attributes.get(db_attributes.DB_SYSTEM_NAME) or attributes.get(
                    SpanAttributes.DB_SYSTEM
                )
                if port != _get_default_port_http(attributes) and port != _get_default_port_db(str(db_system_for_port)):
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Copilot AI review requested due to automatic review settings September 14, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Copilot AI review requested due to automatic review settings September 14, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Install azsdk mcp server

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

Copilot AI review requested due to automatic review settings September 14, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Check stable-first db.operation.name ordering in the trace exporter and QuickPulse mapping.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Copilot AI review requested due to automatic review settings September 14, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved issues were identified, and the changes include regression coverage.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

data.result_code = str(status_code)
elif SpanAttributes.DB_SYSTEM in span.attributes: # Database
db_system = span.attributes[SpanAttributes.DB_SYSTEM]
elif DB_SYSTEM_NAME in span.attributes or SpanAttributes.DB_SYSTEM in span.attributes: # Database

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PR recognizes the new attribute name, but _is_sql_db and _get_default_port_db still recognize only legacy values. The migration guide: https://opentelemetry.io/docs/specs/semconv/non-normative/db-migration/#database-system-name documents renames including mssql → microsoft.sql_server, db2 → ibm.db2, oracle → oracle.db, and h2 → h2database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants