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
26 changes: 10 additions & 16 deletions packages/opentelemetry/src/utils/parseSpanDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {
MESSAGING_QUEUE_PUBLISH_SPAN_OP,
MESSAGING_QUEUE_RECEIVE_SPAN_OP,
MESSAGING_QUEUE_SPAN_OP,
WEB_SERVER_HTTP_CLIENT_SPAN_OP,
WEB_SERVER_HTTP_SERVER_SPAN_OP,
WEB_SERVER_HTTP_SPAN_OP,
} from '@sentry/conventions/op';
import type { Span, SpanAttributes } from '@sentry/core';
import {
Expand Down Expand Up @@ -163,27 +165,19 @@ function descriptionForDbSystem(attributes: Attributes): SpanDescription {

/** Only exported for tests. */
export function descriptionForHttpMethod(attributes: Attributes): SpanDescription {
const opParts = ['http'];
const kind = attributes[SENTRY_KIND];

switch (kind) {
case 'client':
opParts.push('client');
break;
case 'server':
opParts.push('server');
break;
}

// Spans for HTTP requests we have determined to be prefetch requests will have a `.prefetch` postfix in the op
if (attributes['sentry.http.prefetch']) {
opParts.push('prefetch');
}
const op =
kind === 'client'
? WEB_SERVER_HTTP_CLIENT_SPAN_OP
: kind === 'server'
? WEB_SERVER_HTTP_SERVER_SPAN_OP
: WEB_SERVER_HTTP_SPAN_OP;

const { urlPath, url, query, fragment } = getSanitizedUrl(attributes);

if (!urlPath) {
return { op: opParts.join('.') };
return { op };
}

const data: Record<string, string> = {};
Expand All @@ -201,7 +195,7 @@ export function descriptionForHttpMethod(attributes: Attributes): SpanDescriptio
}

return {
op: opParts.join('.'),
op,
Comment thread
msonnb marked this conversation as resolved.
data,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('descriptionForHttpMethod', () => {
[SENTRY_KIND]: 'client' as const,
},
{
op: 'http.client.prefetch',
op: 'http.client',
data: {
'url.full': 'https://www.example.com/my-path',
},
Expand Down
Loading