@sentry/nextjs
Version:
Official Sentry SDK for Next.js
26 lines (22 loc) • 1.26 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const attributes = require('@sentry/conventions/attributes');
const op = require('@sentry/conventions/op');
const nextSpanAttributes = require('../common/nextSpanAttributes.js');
const spanAttributesWithLogicAttached = require('../common/span-attributes-with-logic-attached.js');
function enhanceRunHandlerRootSpan(span) {
const { attributes: attributes$1 } = span;
if (attributes$1[nextSpanAttributes.ATTR_NEXT_SPAN_TYPE] !== "Node.runHandler") {
return;
}
const spanName = attributes$1[nextSpanAttributes.ATTR_NEXT_SPAN_NAME];
if (typeof spanName !== "string" || !spanName.startsWith(spanAttributesWithLogicAttached.ATTR_NEXT_PAGES_API_ROUTE_TYPE)) {
return;
}
span.setOp(op.HTTP_SERVER);
attributes$1[attributes.SENTRY_SEGMENT_NAME_SOURCE] = "route";
const path = spanName.replace(spanAttributesWithLogicAttached.ATTR_NEXT_PAGES_API_ROUTE_TYPE, "").trim();
const method = attributes$1[attributes.HTTP_REQUEST_METHOD] ?? attributes$1[attributes.HTTP_METHOD];
span.setName(`${typeof method === "string" ? method : "GET"} ${path}`);
}
exports.enhanceRunHandlerRootSpan = enhanceRunHandlerRootSpan;
//# sourceMappingURL=enhanceRunHandlerRootSpan.js.map