{"version":3,"file":"MetricStorage.js","sourceRoot":"","sources":["../../../src/state/MetricStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IACvB,qBAAqB,CAAuB;IACtD,YAAY,oBAA0C;QACpD,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IACpD,CAAC;IAaD,uBAAuB;QACrB,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAED,iBAAiB,CAAC,WAAmB;QACnC,IAAI,CAAC,qBAAqB,GAAG,0BAA0B,CACrD,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAC/B,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAC/B;YACE,WAAW,EAAE,WAAW;YACxB,SAAS,EAAE,IAAI,CAAC,qBAAqB,CAAC,SAAS;YAC/C,IAAI,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI;YACrC,MAAM,EAAE,IAAI,CAAC,qBAAqB,CAAC,MAAM;SAC1C,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { HrTime } from '@opentelemetry/api';\nimport type { MetricData } from '../export/MetricData';\nimport type { Maybe } from '../utils';\nimport type { MetricCollectorHandle } from './MetricCollector';\nimport type { InstrumentDescriptor } from '../InstrumentDescriptor';\nimport { createInstrumentDescriptor } from '../InstrumentDescriptor';\n\n/**\n * Internal interface.\n *\n * Represents a storage from which we can collect metrics.\n */\nexport abstract class MetricStorage {\n  protected _instrumentDescriptor: InstrumentDescriptor;\n  constructor(instrumentDescriptor: InstrumentDescriptor) {\n    this._instrumentDescriptor = instrumentDescriptor;\n  }\n\n  /**\n   * Collects the metrics from this storage.\n   *\n   * Note: This is a stateful operation and may reset any interval-related\n   * state for the MetricCollector.\n   */\n  abstract collect(\n    collector: MetricCollectorHandle,\n    collectionTime: HrTime\n  ): Maybe<MetricData>;\n\n  getInstrumentDescriptor(): Readonly<InstrumentDescriptor> {\n    return this._instrumentDescriptor;\n  }\n\n  updateDescription(description: string): void {\n    this._instrumentDescriptor = createInstrumentDescriptor(\n      this._instrumentDescriptor.name,\n      this._instrumentDescriptor.type,\n      {\n        description: description,\n        valueType: this._instrumentDescriptor.valueType,\n        unit: this._instrumentDescriptor.unit,\n        advice: this._instrumentDescriptor.advice,\n      }\n    );\n  }\n}\n"]}