MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / estimateMetricSizeInBytes

Function estimateMetricSizeInBytes

packages/core/src/client.ts:1760–1772  ·  view source on GitHub ↗

* Estimate the size of a metric in bytes. * * @param metric - The metric to estimate the size of. * @returns The estimated size of the metric in bytes.

(metric: Metric)

Source from the content-addressed store, hash-verified

1758 * @returns The estimated size of the metric in bytes.
1759 */
1760function estimateMetricSizeInBytes(metric: Metric): number {
1761 let weight = 0;
1762
1763 // Estimate byte size of 2 bytes per character. This is a rough estimate JS strings are stored as UTF-16.
1764 if (metric.name) {
1765 weight += metric.name.length * 2;
1766 }
1767
1768 // Add weight for number
1769 weight += 8;
1770
1771 return weight + estimateAttributesSizeInBytes(metric.attributes);
1772}
1773
1774/**
1775 * Estimate the size of a log in bytes.

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected