Files
klz-cables.com/.pnpm-store/v10/files/43/e6b334a774667fc6217ef9082648e503671f6d9330b35ddfbb732077dd0db6cfd105f399b8714c815d1f4dd2b1f4c6662d69f524e5f3f7757bb92d1435f18e
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

76 lines
2.3 KiB
Plaintext

import { DEBUG_BUILD } from '../debug-build.js';
import { debug } from './debug-logger.js';
import { isMatchingPattern } from './string.js';
function logIgnoredSpan(droppedSpan) {
debug.log(`Ignoring span ${droppedSpan.op} - ${droppedSpan.description} because it matches \`ignoreSpans\`.`);
}
/**
* Check if a span should be ignored based on the ignoreSpans configuration.
*/
function shouldIgnoreSpan(
span,
ignoreSpans,
) {
if (!ignoreSpans?.length || !span.description) {
return false;
}
for (const pattern of ignoreSpans) {
if (isStringOrRegExp(pattern)) {
if (isMatchingPattern(span.description, pattern)) {
DEBUG_BUILD && logIgnoredSpan(span);
return true;
}
continue;
}
if (!pattern.name && !pattern.op) {
continue;
}
const nameMatches = pattern.name ? isMatchingPattern(span.description, pattern.name) : true;
const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true;
// This check here is only correct because we can guarantee that we ran `isMatchingPattern`
// for at least one of `nameMatches` and `opMatches`. So in contrary to how this looks,
// not both op and name actually have to match. This is the most efficient way to check
// for all combinations of name and op patterns.
if (nameMatches && opMatches) {
DEBUG_BUILD && logIgnoredSpan(span);
return true;
}
}
return false;
}
/**
* Takes a list of spans, and a span that was dropped, and re-parents the child spans of the dropped span to the parent of the dropped span, if possible.
* This mutates the spans array in place!
*/
function reparentChildSpans(spans, dropSpan) {
const droppedSpanParentId = dropSpan.parent_span_id;
const droppedSpanId = dropSpan.span_id;
// This should generally not happen, as we do not apply this on root spans
// but to be safe, we just bail in this case
if (!droppedSpanParentId) {
return;
}
for (const span of spans) {
if (span.parent_span_id === droppedSpanId) {
span.parent_span_id = droppedSpanParentId;
}
}
}
function isStringOrRegExp(value) {
return typeof value === 'string' || value instanceof RegExp;
}
export { reparentChildSpans, shouldIgnoreSpan };
//# sourceMappingURL=should-ignore-span.js.map