Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/opentelemetry/src/utils/parseSpanDescription.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Attributes, AttributeValue } from '@opentelemetry/api';
import { SpanKind } from '@opentelemetry/api';
import {
ATTR_DB_SYSTEM_NAME,
ATTR_HTTP_REQUEST_METHOD,
ATTR_HTTP_ROUTE,
ATTR_URL_FULL,
Expand Down Expand Up @@ -47,7 +48,7 @@ export function inferSpanData(spanName: string, attributes: SpanAttributes, kind
}

// eslint-disable-next-line deprecation/deprecation
const dbSystem = attributes[SEMATTRS_DB_SYSTEM];
const dbSystem = attributes[ATTR_DB_SYSTEM_NAME] || attributes[SEMATTRS_DB_SYSTEM];
const opIsCache =
typeof attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'string' &&
attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP].startsWith('cache.');
Expand Down
43 changes: 43 additions & 0 deletions packages/opentelemetry/test/utils/parseSpanDescription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { Span } from '@opentelemetry/api';
import { SpanKind } from '@opentelemetry/api';
import {
ATTR_DB_SYSTEM_NAME,
ATTR_HTTP_ROUTE,
SEMATTRS_DB_STATEMENT,
SEMATTRS_DB_SYSTEM,
Expand Down Expand Up @@ -147,6 +148,48 @@ describe('parseSpanDescription', () => {
source: 'task',
},
],
[
'works with db.system.name (stable attribute)',
{
[ATTR_DB_SYSTEM_NAME]: 'postgresql',
[SEMATTRS_DB_STATEMENT]: 'SELECT * from users',
},
'test name',
SpanKind.CLIENT,
{
description: 'SELECT * from users',
op: 'db',
source: 'task',
},
],
[
'works with db.system.name without statement',
{
[ATTR_DB_SYSTEM_NAME]: 'postgresql',
},
'test name',
SpanKind.CLIENT,
{
description: 'test name',
op: 'db',
source: 'task',
},
],
[
'prefers db.system.name over deprecated db.system',
{
[ATTR_DB_SYSTEM_NAME]: 'postgresql',
[SEMATTRS_DB_SYSTEM]: 'mysql',
[SEMATTRS_DB_STATEMENT]: 'SELECT * from users',
},
'test name',
SpanKind.CLIENT,
{
description: 'SELECT * from users',
op: 'db',
source: 'task',
},
],
[
'works with rpc service',
{
Expand Down
Loading