All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.esm.tracing.spanstatus.js.map Maven / Gradle / Ivy

There is a newer version: 8.39.0
Show newest version
{"version":3,"file":"spanstatus.js","sources":["../../../src/tracing/spanstatus.ts"],"sourcesContent":["import type { Span, SpanStatus } from '@sentry/types';\n\nexport const SPAN_STATUS_UNSET = 0;\nexport const SPAN_STATUS_OK = 1;\nexport const SPAN_STATUS_ERROR = 2;\n\n/**\n * Converts a HTTP status code into a sentry status with a message.\n *\n * @param httpStatus The HTTP response status code.\n * @returns The span status or unknown_error.\n */\n// https://develop.sentry.dev/sdk/event-payloads/span/\nexport function getSpanStatusFromHttpCode(httpStatus: number): SpanStatus {\n  if (httpStatus < 400 && httpStatus >= 100) {\n    return { code: SPAN_STATUS_OK };\n  }\n\n  if (httpStatus >= 400 && httpStatus < 500) {\n    switch (httpStatus) {\n      case 401:\n        return { code: SPAN_STATUS_ERROR, message: 'unauthenticated' };\n      case 403:\n        return { code: SPAN_STATUS_ERROR, message: 'permission_denied' };\n      case 404:\n        return { code: SPAN_STATUS_ERROR, message: 'not_found' };\n      case 409:\n        return { code: SPAN_STATUS_ERROR, message: 'already_exists' };\n      case 413:\n        return { code: SPAN_STATUS_ERROR, message: 'failed_precondition' };\n      case 429:\n        return { code: SPAN_STATUS_ERROR, message: 'resource_exhausted' };\n      case 499:\n        return { code: SPAN_STATUS_ERROR, message: 'cancelled' };\n      default:\n        return { code: SPAN_STATUS_ERROR, message: 'invalid_argument' };\n    }\n  }\n\n  if (httpStatus >= 500 && httpStatus < 600) {\n    switch (httpStatus) {\n      case 501:\n        return { code: SPAN_STATUS_ERROR, message: 'unimplemented' };\n      case 503:\n        return { code: SPAN_STATUS_ERROR, message: 'unavailable' };\n      case 504:\n        return { code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' };\n      default:\n        return { code: SPAN_STATUS_ERROR, message: 'internal_error' };\n    }\n  }\n\n  return { code: SPAN_STATUS_ERROR, message: 'unknown_error' };\n}\n\n/**\n * Sets the Http status attributes on the current span based on the http code.\n * Additionally, the span's status is updated, depending on the http code.\n */\nexport function setHttpStatus(span: Span, httpStatus: number): void {\n  span.setAttribute('http.response.status_code', httpStatus);\n\n  const spanStatus = getSpanStatusFromHttpCode(httpStatus);\n  if (spanStatus.message !== 'unknown_error') {\n    span.setStatus(spanStatus);\n  }\n}\n"],"names":[],"mappings":"AAEO,MAAM,iBAAkB,GAAE,EAAC;AAC3B,MAAM,cAAe,GAAE,EAAC;AACxB,MAAM,iBAAkB,GAAE,EAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,UAAU,EAAsB;AAC1E,EAAE,IAAI,UAAW,GAAE,OAAO,UAAA,IAAc,GAAG,EAAE;AAC7C,IAAI,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAA;AACnC,GAAE;AACF;AACA,EAAE,IAAI,UAAW,IAAG,OAAO,UAAA,GAAa,GAAG,EAAE;AAC7C,IAAI,QAAQ,UAAU;AACtB,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAA,EAAmB,CAAA;AACtE,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAA,EAAqB,CAAA;AACxE,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,WAAA,EAAa,CAAA;AAChE,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAA,EAAkB,CAAA;AACrE,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,qBAAA,EAAuB,CAAA;AAC1E,MAAM,KAAK,GAAG;AACd,QAAQ,OAAO,EAAE,IAAI,EAAE,iBAAiB,E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