Skip to content

Commit 51b0f5d

Browse files
authored
feat(core): Deprecate spanStatusfromHttpCode in favour of getSpanStatusFromHttpCode (#10361)
The old export contained a typo/camel-case inconsistency which I fixed in the new export and I opted to prepend the `get` verb.
1 parent 2ce3e7d commit 51b0f5d

File tree

13 files changed

+39
-3
lines changed

13 files changed

+39
-3
lines changed

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
@@ -71,7 +71,9 @@ export {
7171
extractTraceparentData,
7272
// eslint-disable-next-line deprecation/deprecation
7373
getActiveTransaction,
74+
// eslint-disable-next-line deprecation/deprecation
7475
spanStatusfromHttpCode,
76+
getSpanStatusFromHttpCode,
7577
// eslint-disable-next-line deprecation/deprecation
7678
trace,
7779
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
@@ -49,7 +49,9 @@ export {
4949
setTag,
5050
setTags,
5151
setUser,
52+
// eslint-disable-next-line deprecation/deprecation
5253
spanStatusfromHttpCode,
54+
getSpanStatusFromHttpCode,
5355
// eslint-disable-next-line deprecation/deprecation
5456
trace,
5557
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,

0 commit comments

Comments
 (0)