Skip to content

Commit 672dae1

Browse files
nicohrubeccodex
andcommitted
ref(core): Use HTTP method constant from conventions
Co-Authored-By: GPT-6 <codex@openai.com>
1 parent 89ac4c2 commit 672dae1

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎packages/astro/src/server/middleware.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {
33
SENTRY_SEGMENT_NAME_SOURCE,
44
HTTP_ROUTE,
5+
HTTP_REQUEST_METHOD,
56
SENTRY_OP,
67
URL_FRAGMENT,
78
URL_FULL,
@@ -19,7 +20,6 @@ import {
1920
hasSpanStreamingEnabled,
2021
HTTP_SPAN_NAME_FALLBACK,
2122
objectify,
22-
SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,
2323
spanToJSON,
2424
winterCGRequestToRequestData,
2525
filterCollectedUrl,
@@ -222,7 +222,7 @@ async function instrumentRequestStartHttpServerSpan(
222222
[SENTRY_OP]: HTTP_SERVER,
223223
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.astro',
224224
[SENTRY_SEGMENT_NAME_SOURCE]: source,
225-
[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: method,
225+
[HTTP_REQUEST_METHOD]: method,
226226
// This is here for backwards compatibility, we used to set this here before
227227
method,
228228
[URL_FULL]: filterCollectedUrl(ctx.url.href),

‎packages/astro/test/server/middleware.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SENTRY_SEGMENT_NAME_SOURCE, URL_FULL, URL_PATH } from '@sentry/conventions/attributes';
1+
import { HTTP_REQUEST_METHOD, SENTRY_SEGMENT_NAME_SOURCE, URL_FULL, URL_PATH } from '@sentry/conventions/attributes';
22
import type { Client, Span } from '@sentry/core';
33

44
import * as SentryCore from '@sentry/core';
@@ -128,7 +128,7 @@ describe('sentryMiddleware', () => {
128128
[URL_FULL]: 'https://mydomain.io/users/123/details',
129129
[URL_PATH]: '/users/123/details',
130130
[SENTRY_SEGMENT_NAME_SOURCE]: 'route',
131-
[SentryCore.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: 'GET',
131+
[HTTP_REQUEST_METHOD]: 'GET',
132132
'http.route': '/users/[id]/details',
133133
},
134134
name: 'GET /users/[id]/details',
@@ -230,7 +230,7 @@ describe('sentryMiddleware', () => {
230230
[URL_FULL]: 'http://localhost:1234/a%xx',
231231
[URL_PATH]: 'a%xx',
232232
[SENTRY_SEGMENT_NAME_SOURCE]: 'url',
233-
[SentryCore.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: 'GET',
233+
[HTTP_REQUEST_METHOD]: 'GET',
234234
},
235235
name: 'GET a%xx',
236236
},

‎packages/browser/src/integrations/graphqlClient.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
hasSpanStreamingEnabled,
55
isObjectLike,
66
isString,
7-
SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,
87
spanToJSON,
98
stringMatchesSomePattern,
109
} from '@sentry/core';
@@ -15,6 +14,7 @@ import {
1514
GRAPHQL_OPERATION_NAME,
1615
GRAPHQL_OPERATION_TYPE,
1716
HTTP_METHOD,
17+
HTTP_REQUEST_METHOD,
1818
SENTRY_OP,
1919
URL_FULL,
2020
} from '@sentry/conventions/attributes';
@@ -77,7 +77,7 @@ function _updateSpanWithGraphQLData(client: Client, options: GraphQLClientOption
7777

7878
const httpUrl = spanAttributes[URL_FULL];
7979
// oxlint-disable-next-line typescript/no-deprecated
80-
const httpMethod = spanAttributes[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes[HTTP_METHOD];
80+
const httpMethod = spanAttributes[HTTP_REQUEST_METHOD] || spanAttributes[HTTP_METHOD];
8181

8282
if (!isString(httpUrl) || !isString(httpMethod)) {
8383
return;

‎packages/bun/src/integrations/bunserver.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
HTTP_SPAN_NAME_FALLBACK,
1313
isURLObjectRelative,
1414
parseStringToURLObject,
15-
SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,
1615
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
1716
setHttpStatus,
1817
startSpan,
@@ -26,6 +25,7 @@ import type { Server, ServeOptions } from 'bun';
2625
import {
2726
CLIENT_ADDRESS,
2827
CLIENT_PORT,
28+
HTTP_REQUEST_METHOD,
2929
NETWORK_PROTOCOL_NAME,
3030
SENTRY_OP,
3131
SENTRY_SEGMENT_NAME_SOURCE,
@@ -356,7 +356,7 @@ function getSpanAttributesFromParsedUrl(
356356
): SpanAttributes {
357357
const attributes: SpanAttributes = {
358358
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.bun.serve',
359-
[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: request.method || 'GET',
359+
[HTTP_REQUEST_METHOD]: request.method || 'GET',
360360
[SENTRY_SEGMENT_NAME_SOURCE]: 'url',
361361
};
362362

‎packages/core/src/semanticAttributes.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ export const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';
105105

106106
export const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';
107107

108-
/** TODO: Remove these once we update to latest semantic conventions */
108+
/**
109+
* @deprecated Use `HTTP_REQUEST_METHOD` from `@sentry/conventions/attributes` instead.
110+
*/
109111
export const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';
110112
/**
111113
* @deprecated Use `URL_FULL` `@sentry/conventions/attributes` instead.

‎packages/core/src/utils/url.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
HTTP_REQUEST_METHOD,
23
HTTP_ROUTE,
34
SERVER_ADDRESS,
45
URL_DOMAIN,
@@ -11,7 +12,7 @@ import {
1112
URL_SCHEME,
1213
URL_TEMPLATE,
1314
} from '@sentry/conventions/attributes';
14-
import { SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
15+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
1516
import type { Client } from '../client';
1617
import type { SpanAttributes } from '../types/span';
1718
import type { TransactionSource } from '../types/transaction';
@@ -221,7 +222,7 @@ export function getHttpSpanDetailsFromUrlObject(
221222
}
222223

223224
if (request?.method) {
224-
attributes[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] = request.method.toUpperCase();
225+
attributes[HTTP_REQUEST_METHOD] = request.method.toUpperCase();
225226
}
226227

227228
if (urlObject) {

0 commit comments

Comments
 (0)