|
1 | 1 | import type { Client, ClientOptions, MeasurementUnit, Primitive } from '@sentry/types'; |
2 | 2 | import { timestampInSeconds } from '@sentry/utils'; |
3 | | -import { DEFAULT_FLUSH_INTERVAL, NAME_AND_TAG_KEY_REGEX, TAG_VALUE_REGEX } from './constants'; |
| 3 | +import { |
| 4 | + DEFAULT_FLUSH_INTERVAL, |
| 5 | + NAME_AND_TAG_KEY_NORMALIZATION_REGEX, |
| 6 | + TAG_VALUE_NORMALIZATION_REGEX, |
| 7 | +} from './constants'; |
4 | 8 | import type { Metric } from './instance'; |
5 | 9 | import { METRIC_MAP } from './instance'; |
6 | 10 | import type { MetricType, MetricsAggregator } from './types'; |
@@ -45,7 +49,7 @@ export class SimpleMetricsAggregator implements MetricsAggregator { |
45 | 49 | maybeFloatTimestamp = timestampInSeconds(), |
46 | 50 | ): void { |
47 | 51 | const timestamp = Math.floor(maybeFloatTimestamp); |
48 | | - const name = unsanitizedName.replace(NAME_AND_TAG_KEY_REGEX, '_'); |
| 52 | + const name = unsanitizedName.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); |
49 | 53 | const tags = sanitizeTags(unsanitizedTags); |
50 | 54 |
|
51 | 55 | const bucketKey = getBucketKey(metricType, name, unit, tags); |
@@ -112,8 +116,8 @@ function sanitizeTags(unsanitizedTags: { [key: string]: Primitive }): { [key: st |
112 | 116 | const tags: { [key: string]: string } = {}; |
113 | 117 | for (const key in unsanitizedTags) { |
114 | 118 | if (Object.prototype.hasOwnProperty.call(unsanitizedTags, key)) { |
115 | | - const sanitizedKey = key.replace(NAME_AND_TAG_KEY_REGEX, '_'); |
116 | | - tags[sanitizedKey] = String(unsanitizedTags[key]).replace(TAG_VALUE_REGEX, '_'); |
| 119 | + const sanitizedKey = key.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); |
| 120 | + tags[sanitizedKey] = String(unsanitizedTags[key]).replace(TAG_VALUE_NORMALIZATION_REGEX, '_'); |
117 | 121 | } |
118 | 122 | } |
119 | 123 | return tags; |
|
0 commit comments