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
30 lines
750 B
Plaintext
30 lines
750 B
Plaintext
import { winterCGHeadersToDict, httpHeadersToSpanAttributes, getClient } from '@sentry/core';
|
|
|
|
/**
|
|
* Extracts HTTP request headers as span attributes and optionally applies them to a span.
|
|
*/
|
|
function addHeadersAsAttributes(
|
|
headers,
|
|
span,
|
|
) {
|
|
if (!headers) {
|
|
return {};
|
|
}
|
|
|
|
const headersDict =
|
|
headers instanceof Headers || (typeof headers === 'object' && 'get' in headers)
|
|
? winterCGHeadersToDict(headers )
|
|
: headers;
|
|
|
|
const headerAttributes = httpHeadersToSpanAttributes(headersDict, getClient()?.getOptions().sendDefaultPii ?? false);
|
|
|
|
if (span) {
|
|
span.setAttributes(headerAttributes);
|
|
}
|
|
|
|
return headerAttributes;
|
|
}
|
|
|
|
export { addHeadersAsAttributes };
|
|
//# sourceMappingURL=addHeadersAsAttributes.js.map
|