* 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)
| 1758 | * @returns The estimated size of the metric in bytes. |
| 1759 | */ |
| 1760 | function 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. |
nothing calls this directly
no test coverage detected