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AC5B,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CACxD,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InstrumentationScope } from '@opentelemetry/core';\nimport { InstrumentDescriptor } from '../InstrumentDescriptor';\nimport { InstrumentSelector } from './InstrumentSelector';\nimport { MeterSelector } from './MeterSelector';\nimport { View } from './View';\n\nexport class ViewRegistry {\n  private _registeredViews: View[] = [];\n\n  addView(view: View) {\n    this._registeredViews.push(view);\n  }\n\n  findViews(\n    instrument: InstrumentDescriptor,\n    meter: InstrumentationScope\n  ): View[] {\n    const views = this._registeredViews.filter(registeredView => {\n      return (\n        this._matchInstrument(registeredView.instrumentSelector, instrument) &&\n        this._matchMeter(registeredView.meterSelector, meter)\n      );\n    });\n\n    return views;\n  }\n\n  private _matchInstrument(\n    selector: InstrumentSelector,\n    instrument: InstrumentDescriptor\n  ): boolean {\n    return (\n      (selector.getType() === undefined ||\n        instrument.type === selector.getType()) &&\n      selector.getNameFilter().match(instrument.name) &&\n      selector.getUnitFilter().match(instrument.unit)\n    );\n  }\n\n  private _matchMeter(\n    selector: MeterSelector,\n    meter: InstrumentationScope\n  ): boolean {\n    return (\n      selector.getNameFilter().match(meter.name) &&\n      (meter.version === undefined ||\n        selector.getVersionFilter().match(meter.version)) &&\n      (meter.schemaUrl === undefined ||\n        selector.getSchemaUrlFilter().match(meter.schemaUrl))\n    );\n  }\n}\n"]}