{"version":3,"file":"MeterProviderSharedState.cjs","names":["ViewRegistry","instrumentationScopeId","MeterSharedState","toAggregation"],"sources":["../../src/state/MeterProviderSharedState.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport type { Resource } from '@opentelemetry/resources';\nimport { instrumentationScopeId } from '../utils';\nimport { ViewRegistry } from '../view/ViewRegistry';\nimport { MeterSharedState } from './MeterSharedState';\nimport type { MetricCollector, MetricCollectorHandle } from './MetricCollector';\nimport { toAggregation } from '../view/AggregationOption';\nimport type { Aggregation } from '../view/Aggregation';\nimport type { InstrumentType } from '../export/MetricData';\n\n/**\n * An internal record for shared meter provider states.\n */\nexport class MeterProviderSharedState {\n  viewRegistry = new ViewRegistry();\n\n  metricCollectors: MetricCollector[] = [];\n\n  meterSharedStates: Map<string, MeterSharedState> = new Map();\n  public resource: Resource;\n\n  constructor(resource: Resource) {\n    this.resource = resource;\n  }\n\n  getMeterSharedState(instrumentationScope: InstrumentationScope) {\n    const id = instrumentationScopeId(instrumentationScope);\n    let meterSharedState = this.meterSharedStates.get(id);\n    if (meterSharedState == null) {\n      meterSharedState = new MeterSharedState(this, instrumentationScope);\n      this.meterSharedStates.set(id, meterSharedState);\n    }\n    return meterSharedState;\n  }\n\n  selectAggregations(instrumentType: InstrumentType) {\n    const result: [MetricCollectorHandle, Aggregation][] = [];\n    for (const collector of this.metricCollectors) {\n      result.push([\n        collector,\n        toAggregation(collector.selectAggregation(instrumentType)),\n      ]);\n    }\n    return result;\n  }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,2BAAb,MAAsC;CACpC,eAAe,IAAIA,qBAAAA,aAAa;CAEhC,mBAAsC,CAAC;CAEvC,oCAAmD,IAAI,IAAI;CAC3D;CAEA,YAAY,UAAoB;EAC9B,KAAK,WAAW;CAClB;CAEA,oBAAoB,sBAA4C;EAC9D,MAAM,KAAKC,cAAAA,uBAAuB,oBAAoB;EACtD,IAAI,mBAAmB,KAAK,kBAAkB,IAAI,EAAE;EACpD,IAAI,oBAAoB,MAAM;GAC5B,mBAAmB,IAAIC,yBAAAA,iBAAiB,MAAM,oBAAoB;GAClE,KAAK,kBAAkB,IAAI,IAAI,gBAAgB;EACjD;EACA,OAAO;CACT;CAEA,mBAAmB,gBAAgC;EACjD,MAAM,SAAiD,CAAC;EACxD,KAAK,MAAM,aAAa,KAAK,kBAC3B,OAAO,KAAK,CACV,WACAC,0BAAAA,cAAc,UAAU,kBAAkB,cAAc,CAAC,CAC3D,CAAC;EAEH,OAAO;CACT;AACF"}