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

package.build.cjs.metrics.instance.js.map Maven / Gradle / Ivy

There is a newer version: 8.39.0
Show newest version
{"version":3,"file":"instance.js","sources":["../../../src/metrics/instance.ts"],"sourcesContent":["import type { MetricInstance } from '@sentry/types';\nimport { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, SET_METRIC_TYPE } from './constants';\nimport { simpleHash } from './utils';\n\n/**\n * A metric instance representing a counter.\n */\nexport class CounterMetric implements MetricInstance {\n  public constructor(private _value: number) {}\n\n  /** @inheritDoc */\n  public get weight(): number {\n    return 1;\n  }\n\n  /** @inheritdoc */\n  public add(value: number): void {\n    this._value += value;\n  }\n\n  /** @inheritdoc */\n  public toString(): string {\n    return `${this._value}`;\n  }\n}\n\n/**\n * A metric instance representing a gauge.\n */\nexport class GaugeMetric implements MetricInstance {\n  private _last: number;\n  private _min: number;\n  private _max: number;\n  private _sum: number;\n  private _count: number;\n\n  public constructor(value: number) {\n    this._last = value;\n    this._min = value;\n    this._max = value;\n    this._sum = value;\n    this._count = 1;\n  }\n\n  /** @inheritDoc */\n  public get weight(): number {\n    return 5;\n  }\n\n  /** @inheritdoc */\n  public add(value: number): void {\n    this._last = value;\n    if (value < this._min) {\n      this._min = value;\n    }\n    if (value > this._max) {\n      this._max = value;\n    }\n    this._sum += value;\n    this._count++;\n  }\n\n  /** @inheritdoc */\n  public toString(): string {\n    return `${this._last}:${this._min}:${this._max}:${this._sum}:${this._count}`;\n  }\n}\n\n/**\n * A metric instance representing a distribution.\n */\nexport class DistributionMetric implements MetricInstance {\n  private _value: number[];\n\n  public constructor(first: number) {\n    this._value = [first];\n  }\n\n  /** @inheritDoc */\n  public get weight(): number {\n    return this._value.length;\n  }\n\n  /** @inheritdoc */\n  public add(value: number): void {\n    this._value.push(value);\n  }\n\n  /** @inheritdoc */\n  public toString(): string {\n    return this._value.join(':');\n  }\n}\n\n/**\n * A metric instance representing a set.\n */\nexport class SetMetric implements MetricInstance {\n  private _value: Set;\n\n  public constructor(public first: number | string) {\n    this._value = new Set([first]);\n  }\n\n  /** @inheritDoc */\n  public get weight(): number {\n    return this._value.size;\n  }\n\n  /** @inheritdoc */\n  public add(value: number | string): void {\n    this._value.add(value);\n  }\n\n  /** @inheritdoc */\n  public toString(): string {\n    return Array.from(this._value)\n      .map(val => (typeof val === 'string' ? simpleHash(val) : val))\n      .join(':');\n  }\n}\n\nexport const METRIC_MAP = {\n  [COUNTER_METRIC_TYPE]: CounterMetric,\n  [GAUGE_METRIC_TYPE]: GaugeMetric,\n  [DISTRIBUTION_METRIC_TYPE]: DistributionMetric,\n  [SET_METRIC_TYPE]: SetMetric,\n};\n"],"names":["simpleHash","COUNTER_METRIC_TYPE","GAUGE_METRIC_TYPE","DISTRIBUTION_METRIC_TYPE","SET_METRIC_TYPE"],"mappings":";;;;;AAIA;AACA;AACA;AACO,MAAM,eAAwC;AACrD,GAAS,WAAW,EAAS,MAAM,EAAU,CAAC,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA,CAAA;AAC9C;AACA;AACA,GAAS,IAAI,MAAM,GAAW;AAC9B,IAAI,OAAO,CAAC,CAAA;AACZ,GAAE;AACF;AACA;AACA,GAAS,GAAG,CAAC,KAAK,EAAgB;AAClC,IAAI,IAAI,CAAC,MAAO,IAAG,KAAK,CAAA;AACxB,GAAE;AACF;AACA;AACA,GAAS,QAAQ,GAAW;AAC5B,IAAI,OAAO,CAAC,EAAA,IAAA,CAAA,MAAA,CAAA,CAAA,CAAA;AACA,GAAA;AACA,CAAA;AACA;AACA;AACA;AACA;AACA,MAAA,WAAA,EAAA;;AAOA,GAAA,WAAA,CAAA,KAAA,EAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,KAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,KAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,KAA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