UNPKG

@sentry/core

Version:
25 lines (24 loc) • 1.03 kB
import { estimateTypedAttributesSizeInBytes } from "../../attributes.js"; // src/tracing/spans/estimateSize.ts /** * Estimates the serialized byte size of a {@link SerializedStreamedSpan}. * * Uses 2 bytes per character as a UTF-16 approximation, and 8 bytes per number. * The estimate is intentionally conservative and may be slightly lower than the * actual byte size on the wire. * We compensate for this by setting the span buffers internal limit well below the limit * of how large an actual span v2 envelope may be. */ function estimateSerializedSpanSizeInBytes(span) { let weight = 156; weight += span.name.length * 2; weight += estimateTypedAttributesSizeInBytes(span.attributes); if (span.links && span.links.length > 0) { const attributes = span.links[0]?.attributes; const linkWeight = 100 + (attributes ? estimateTypedAttributesSizeInBytes(attributes) : 0); weight += linkWeight * span.links.length; } return weight; } export { estimateSerializedSpanSizeInBytes }; //# sourceMappingURL=estimateSize.js.map