UNPKG

@sentry/nextjs

Version:
24 lines (21 loc) 787 B
import { stripUrlQueryAndFragment } from '@sentry/core'; import { ATTR_NEXT_SPAN_TYPE, ATTR_NEXT_SPAN_NAME } from './nextSpanAttributes.js'; function enhanceMiddlewareRootSpan(span) { const { attributes } = span; if (attributes[ATTR_NEXT_SPAN_TYPE] !== "Middleware.execute") { return; } span.setOp("http.server.middleware"); const spanName = attributes[ATTR_NEXT_SPAN_NAME]; if (typeof spanName !== "string" || !spanName || !span.getName()) { return; } const match = spanName.match(/^middleware (GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)/); if (match) { span.setName(`middleware ${match[1]}`); } else { span.setName(stripUrlQueryAndFragment(spanName)); } } export { enhanceMiddlewareRootSpan }; //# sourceMappingURL=enhanceMiddlewareRootSpan.js.map