{"version":3,"file":"MetricStorage.cjs","names":["createInstrumentDescriptor"],"sources":["../../src/state/MetricStorage.ts"],"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"],"mappings":";;;;;;;AAiBA,IAAsB,gBAAtB,MAAoC;CAClC;CACA,YAAY,sBAA4C;EACtD,KAAK,wBAAwB;CAC/B;CAaA,0BAA0D;EACxD,OAAO,KAAK;CACd;CAEA,kBAAkB,aAA2B;EAC3C,KAAK,wBAAwBA,6BAAAA,2BAC3B,KAAK,sBAAsB,MAC3B,KAAK,sBAAsB,MAC3B;GACe;GACb,WAAW,KAAK,sBAAsB;GACtC,MAAM,KAAK,sBAAsB;GACjC,QAAQ,KAAK,sBAAsB;EACrC,CACF;CACF;AACF"}