Skip to content

feat(core): Deprecate spanStatusfromHttpCode in favour of getSpanStatusFromHttpCode #10361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2024
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
2 changes: 2 additions & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export {
extractTraceparentData,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
makeMultiplexedTransport,
Expand Down
2 changes: 2 additions & 0 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/tracing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export { Transaction } from './transaction';
export { extractTraceparentData, getActiveTransaction } from './utils';
// eslint-disable-next-line deprecation/deprecation
export { SpanStatus } from './spanstatus';
export { setHttpStatus, spanStatusfromHttpCode } from './spanstatus';
export {
setHttpStatus,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
} from './spanstatus';
export type { SpanStatusType } from './spanstatus';
export {
// eslint-disable-next-line deprecation/deprecation
Expand Down
15 changes: 13 additions & 2 deletions packages/core/src/tracing/spanstatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export type SpanStatusType =
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
export function spanStatusfromHttpCode(httpStatus: number): SpanStatusType {
export function getSpanStatusFromHttpCode(httpStatus: number): SpanStatusType {
if (httpStatus < 400 && httpStatus >= 100) {
return 'ok';
}
Expand Down Expand Up @@ -123,6 +123,17 @@ export function spanStatusfromHttpCode(httpStatus: number): SpanStatusType {
return 'unknown_error';
}

/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @deprecated Use {@link spanStatusFromHttpCode} instead.
* This export will be removed in v8 as the signature contains a typo.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
export const spanStatusfromHttpCode = getSpanStatusFromHttpCode;

/**
* Sets the Http status attributes on the current span based on the http code.
* Additionally, the span's status is updated, depending on the http code.
Expand All @@ -140,7 +151,7 @@ export function setHttpStatus(span: Span, httpStatus: number): void {
// eslint-disable-next-line deprecation/deprecation
span.setData('http.response.status_code', httpStatus);

const spanStatus = spanStatusfromHttpCode(httpStatus);
const spanStatus = getSpanStatusFromHttpCode(httpStatus);
if (spanStatus !== 'unknown_error') {
span.setStatus(spanStatus);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
2 changes: 2 additions & 0 deletions packages/node-experimental/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export {
Hub,
runWithAsyncContext,
SDK_VERSION,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
captureCheckIn,
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
2 changes: 2 additions & 0 deletions packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
2 changes: 2 additions & 0 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down
1 change: 1 addition & 0 deletions packages/tracing-internal/src/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
Span,
// eslint-disable-next-line deprecation/deprecation
SpanStatus,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
startIdleTransaction,
Transaction,
Expand Down
1 change: 1 addition & 0 deletions packages/tracing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const extractTraceparentData = extractTraceparentDataT;
*
* `spanStatusfromHttpCode` can be imported from `@sentry/node`, `@sentry/browser`, or your framework SDK
*/
// eslint-disable-next-line deprecation/deprecation
export const spanStatusfromHttpCode = spanStatusfromHttpCodeT;

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/vercel-edge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export {
setTag,
setTags,
setUser,
// eslint-disable-next-line deprecation/deprecation
spanStatusfromHttpCode,
getSpanStatusFromHttpCode,
// eslint-disable-next-line deprecation/deprecation
trace,
withScope,
Expand Down