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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ function descriptionForHttpMethod(otelSpan: OtelSpan, httpMethod: AttributeValue

// Ex. description="GET /api/users".
const description = `${httpMethod} ${httpPath}`;
const source: TransactionSource = httpRoute ? 'route' : 'url';

// If `httpPath` is a root path, then we can categorize the transaction source as route.
const source: TransactionSource = httpRoute || httpPath === '/' ? 'route' : 'url';

return { op: opParts.join('.'), description, source };
}
15 changes: 15 additions & 0 deletions packages/opentelemetry-node/test/spanprocessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,21 @@ describe('SentrySpanProcessor', () => {
});
});

it('adds transaction source `route` for root path HTTP_TARGET', async () => {
const tracer = provider.getTracer('default');

tracer.startActiveSpan('GET /', otelSpan => {
const sentrySpan = getSpanForOtelSpan(otelSpan);

otelSpan.setAttribute(SemanticAttributes.HTTP_METHOD, 'GET');
otelSpan.setAttribute(SemanticAttributes.HTTP_TARGET, '/');

otelSpan.end();

expect(sentrySpan?.transaction?.metadata.source).toBe('route');
});
});

it('adds transaction source `url` for HTTP_ROUTE', async () => {
const tracer = provider.getTracer('default');

Expand Down