Skip to content

chore(otlp-exporter): corrected span name for db - #2850

Closed
aryamohanan wants to merge 2 commits into
feat-otlp-exporterfrom
chore-span-name
Closed

aryamohanan wants to merge 2 commits into
feat-otlp-exporterfrom
chore-span-name

Conversation

@aryamohanan

@aryamohanan aryamohanan commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

The current span name mapping for db is not align with otel spec.

reference: https://opentelemetry.io/docs/specs/semconv/db/database-spans/#name


[INSTRUMENTATION_TYPES.PG]: {
spanName: data => `pg.${data.stmt?.split(/\s+/)[0]?.toUpperCase()}`,
spanName: data => getSqlOperation(data.stmt) || data.db || 'postgresql',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In 99% of regular cases, getSqlOperation(data.stmt) evaluates to the SQL verb (e.g. SELECT, INSERT).

The fallback || data.db || provides defensive safety against edge cases, ensuring compliance with the OpenTelemetry specification so the span name is never undefined.

@aryamohanan
aryamohanan marked this pull request as ready for review October 26, 2026 12:06
@aryamohanan
aryamohanan requested a review from a team as a code owner October 26, 2026 12:06

@abhilash-sivan abhilash-sivan 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.

I agree with the OTEL naming convention.
Don't remember why we kept custom naming with library names.

@kirrg001 kirrg001 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.

We agreed a few weeks ago to go with the version we use in main, because the docs on Otel were not clear and the majority of references use this notation.

@aryamohanan

Copy link
Copy Markdown
Member Author

We agreed a few weeks ago to go with the version we use in main, because the docs on Otel were not clear and the majority of references use this notation.

Closing on favour of this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants