All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.esm.metrics.metric-summary.js.map Maven / Gradle / Ivy

There is a newer version: 8.39.0
Show newest version
{"version":3,"file":"metric-summary.js","sources":["../../../src/metrics/metric-summary.ts"],"sourcesContent":["import type { MeasurementUnit, Span } from '@sentry/types';\nimport type { MetricSummary } from '@sentry/types';\nimport type { Primitive } from '@sentry/types';\nimport { dropUndefinedKeys } from '@sentry/utils';\nimport type { MetricType } from './types';\n\n/**\n * key: bucketKey\n * value: [exportKey, MetricSummary]\n */\ntype MetricSummaryStorage = Map;\n\nconst METRICS_SPAN_FIELD = '_sentryMetrics';\n\ntype SpanWithPotentialMetrics = Span & {\n  [METRICS_SPAN_FIELD]?: MetricSummaryStorage;\n};\n\n/**\n * Fetches the metric summary if it exists for the passed span\n */\nexport function getMetricSummaryJsonForSpan(span: Span): Record> | undefined {\n  const storage = (span as SpanWithPotentialMetrics)[METRICS_SPAN_FIELD];\n\n  if (!storage) {\n    return undefined;\n  }\n  const output: Record> = {};\n\n  for (const [, [exportKey, summary]] of storage) {\n    const arr = output[exportKey] || (output[exportKey] = []);\n    arr.push(dropUndefinedKeys(summary));\n  }\n\n  return output;\n}\n\n/**\n * Updates the metric summary on a span.\n */\nexport function updateMetricSummaryOnSpan(\n  span: Span,\n  metricType: MetricType,\n  sanitizedName: string,\n  value: number,\n  unit: MeasurementUnit,\n  tags: Record,\n  bucketKey: string,\n): void {\n  const existingStorage = (span as SpanWithPotentialMetrics)[METRICS_SPAN_FIELD];\n  const storage =\n    existingStorage ||\n    ((span as SpanWithPotentialMetrics)[METRICS_SPAN_FIELD] = new Map());\n\n  const exportKey = `${metricType}:${sanitizedName}@${unit}`;\n  const bucketItem = storage.get(bucketKey);\n\n  if (bucketItem) {\n    const [, summary] = bucketItem;\n    storage.set(bucketKey, [\n      exportKey,\n      {\n        min: Math.min(summary.min, value),\n        max: Math.max(summary.max, value),\n        count: (summary.count += 1),\n        sum: (summary.sum += value),\n        tags: summary.tags,\n      },\n    ]);\n  } else {\n    storage.set(bucketKey, [\n      exportKey,\n      {\n        min: value,\n        max: value,\n        count: 1,\n        sum: value,\n        tags,\n      },\n    ]);\n  }\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACA;;AAGA,MAAM,kBAAA,GAAqB,gBAAgB,CAAA;;AAM3C;AACA;AACA;AACO,SAAS,2BAA2B,CAAC,IAAI,EAA0D;AAC1G,EAAE,MAAM,UAAU,CAAC,OAAkC,kBAAkB,CAAC,CAAA;AACxE;AACA,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,OAAO,SAAS,CAAA;AACpB,GAAE;AACF,EAAE,MAAM,MAAM,GAAyC,EAAE,CAAA;AACzD;AACA,EAAE,KAAK,MAAM,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAE,IAAG,OAAO,EAAE;AAClD,IAAI,MAAM,GAAI,GAAE,MAAM,CAAC,SAAS,CAAE,KAAI,MAAM,CAAC,SAAS,CAAA,GAAI,EAAE,CAAC,CAAA;AAC7D,IAAI,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAA;AACxC,GAAE;AACF;AACA,EAAE,OAAO,MAAM,CAAA;AACf,CAAA;AACA;AACA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,IAAI;AACN,EAAE,UAAU;AACZ,EAAE,aAAa;AACf,EAAE,KAAK;AACP,EAAE,IAAI;AACN,EAAE,IAAI;AACN,EAAE,SAAS;AACX,EAAQ;AACR,EAAE,MAAM,kBAAkB,CAAC,OAAkC,kBAAkB,CAAC,CAAA;AAChF,EAAE,MAAM,OAAQ;AAChB,IAAI,eAAgB;AACpB,KAAK,CAAC,IAAK,GAA6B,kBAAkB,CAAE,GAAE,IAAI,GAAG,EAAmC,CAAC,CAAA;AACzG;AACA,EAAE,MAAM,SAAA,GAAY,CAAC,EAAA,UAAA,CAAA,CAAA,EAAA,aAAA,CAAA,CAAA,EAAA,IAAA,CAAA,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