Skip to content

Commit 55c6df2

Browse files
committed
feat(core): Deprecate spanStatusfromHttpCode in favour of getSpanStatusFromHttpCode
1 parent f4535b6 commit 55c6df2

File tree

14 files changed

+41
-4
lines changed

14 files changed

+41
-4
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"editor.codeActionsOnSave": {
3939
"source.organizeImports.biome": "explicit",
4040
},
41-
"editor.defaultFormatter": "biomejs.biome"
41+
"editor.defaultFormatter": "biomejs.biome",
42+
"cSpell.words": ["Statusfrom"]
4243
}

packages/astro/src/index.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export {
4646
setTag,
4747
setTags,
4848
setUser,
49+
// eslint-disable-next-line deprecation/deprecation
4950
spanStatusfromHttpCode,
51+
getSpanStatusFromHttpCode,
5052
// eslint-disable-next-line deprecation/deprecation
5153
trace,
5254
withScope,

packages/browser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export {
6666
extractTraceparentData,
6767
// eslint-disable-next-line deprecation/deprecation
6868
getActiveTransaction,
69+
// eslint-disable-next-line deprecation/deprecation
6970
spanStatusfromHttpCode,
71+
getSpanStatusFromHttpCode,
7072
// eslint-disable-next-line deprecation/deprecation
7173
trace,
7274
makeMultiplexedTransport,

packages/bun/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export {
6666
setTag,
6767
setTags,
6868
setUser,
69+
// eslint-disable-next-line deprecation/deprecation
6970
spanStatusfromHttpCode,
71+
getSpanStatusFromHttpCode,
7072
// eslint-disable-next-line deprecation/deprecation
7173
trace,
7274
withScope,

packages/core/src/tracing/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export { Transaction } from './transaction';
77
export { extractTraceparentData, getActiveTransaction } from './utils';
88
// eslint-disable-next-line deprecation/deprecation
99
export { SpanStatus } from './spanstatus';
10-
export { setHttpStatus, spanStatusfromHttpCode } from './spanstatus';
10+
export {
11+
setHttpStatus,
12+
// eslint-disable-next-line deprecation/deprecation
13+
spanStatusfromHttpCode,
14+
getSpanStatusFromHttpCode,
15+
} from './spanstatus';
1116
export type { SpanStatusType } from './spanstatus';
1217
export {
1318
// eslint-disable-next-line deprecation/deprecation

packages/core/src/tracing/spanstatus.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export type SpanStatusType =
8383
* @param httpStatus The HTTP response status code.
8484
* @returns The span status or unknown_error.
8585
*/
86-
export function spanStatusfromHttpCode(httpStatus: number): SpanStatusType {
86+
export function getSpanStatusFromHttpCode(httpStatus: number): SpanStatusType {
8787
if (httpStatus < 400 && httpStatus >= 100) {
8888
return 'ok';
8989
}
@@ -123,6 +123,17 @@ export function spanStatusfromHttpCode(httpStatus: number): SpanStatusType {
123123
return 'unknown_error';
124124
}
125125

126+
/**
127+
* Converts a HTTP status code into a {@link SpanStatusType}.
128+
*
129+
* @deprecated Use {@link spanStatusFromHttpCode} instead.
130+
* This export will be removed in v8 as the signature contains a typo.
131+
*
132+
* @param httpStatus The HTTP response status code.
133+
* @returns The span status or unknown_error.
134+
*/
135+
export const spanStatusfromHttpCode = getSpanStatusFromHttpCode;
136+
126137
/**
127138
* Sets the Http status attributes on the current span based on the http code.
128139
* Additionally, the span's status is updated, depending on the http code.
@@ -140,7 +151,7 @@ export function setHttpStatus(span: Span, httpStatus: number): void {
140151
// eslint-disable-next-line deprecation/deprecation
141152
span.setData('http.response.status_code', httpStatus);
142153

143-
const spanStatus = spanStatusfromHttpCode(httpStatus);
154+
const spanStatus = getSpanStatusFromHttpCode(httpStatus);
144155
if (spanStatus !== 'unknown_error') {
145156
span.setStatus(spanStatus);
146157
}

packages/deno/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export {
6565
setTag,
6666
setTags,
6767
setUser,
68+
// eslint-disable-next-line deprecation/deprecation
6869
spanStatusfromHttpCode,
70+
getSpanStatusFromHttpCode,
6971
// eslint-disable-next-line deprecation/deprecation
7072
trace,
7173
withScope,

packages/node-experimental/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export {
6666
Hub,
6767
runWithAsyncContext,
6868
SDK_VERSION,
69+
// eslint-disable-next-line deprecation/deprecation
6970
spanStatusfromHttpCode,
71+
getSpanStatusFromHttpCode,
7072
// eslint-disable-next-line deprecation/deprecation
7173
trace,
7274
captureCheckIn,

packages/node/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export {
6565
setTag,
6666
setTags,
6767
setUser,
68+
// eslint-disable-next-line deprecation/deprecation
6869
spanStatusfromHttpCode,
70+
getSpanStatusFromHttpCode,
6971
// eslint-disable-next-line deprecation/deprecation
7072
trace,
7173
withScope,

packages/remix/src/index.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export {
4444
setTag,
4545
setTags,
4646
setUser,
47+
// eslint-disable-next-line deprecation/deprecation
4748
spanStatusfromHttpCode,
49+
getSpanStatusFromHttpCode,
4850
// eslint-disable-next-line deprecation/deprecation
4951
trace,
5052
withScope,

packages/sveltekit/src/server/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export {
4343
setTag,
4444
setTags,
4545
setUser,
46+
// eslint-disable-next-line deprecation/deprecation
4647
spanStatusfromHttpCode,
48+
getSpanStatusFromHttpCode,
4749
// eslint-disable-next-line deprecation/deprecation
4850
trace,
4951
withScope,

packages/tracing-internal/src/exports/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {
88
Span,
99
// eslint-disable-next-line deprecation/deprecation
1010
SpanStatus,
11+
// eslint-disable-next-line deprecation/deprecation
1112
spanStatusfromHttpCode,
1213
startIdleTransaction,
1314
Transaction,

packages/tracing/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const extractTraceparentData = extractTraceparentDataT;
7878
*
7979
* `spanStatusfromHttpCode` can be imported from `@sentry/node`, `@sentry/browser`, or your framework SDK
8080
*/
81+
// eslint-disable-next-line deprecation/deprecation
8182
export const spanStatusfromHttpCode = spanStatusfromHttpCodeT;
8283

8384
/**

packages/vercel-edge/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export {
6565
setTag,
6666
setTags,
6767
setUser,
68+
// eslint-disable-next-line deprecation/deprecation
6869
spanStatusfromHttpCode,
70+
getSpanStatusFromHttpCode,
6971
// eslint-disable-next-line deprecation/deprecation
7072
trace,
7173
withScope,

0 commit comments

Comments
 (0)