{"version":3,"file":"ViewRegistry.cjs","names":[],"sources":["../../src/view/ViewRegistry.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport type { InstrumentDescriptor } from '../InstrumentDescriptor';\nimport type { InstrumentSelector } from './InstrumentSelector';\nimport type { MeterSelector } from './MeterSelector';\nimport type { 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"],"mappings":";AAWA,IAAa,eAAb,MAA0B;CACxB,mBAAmC,CAAC;CAEpC,QAAQ,MAAY;EAClB,KAAK,iBAAiB,KAAK,IAAI;CACjC;CAEA,UACE,YACA,OACQ;EAQR,OAPc,KAAK,iBAAiB,QAAO,mBAAkB;GAC3D,OACE,KAAK,iBAAiB,eAAe,oBAAoB,UAAU,KACnE,KAAK,YAAY,eAAe,eAAe,KAAK;EAExD,CAEW;CACb;CAEA,iBACE,UACA,YACS;EACT,QACG,SAAS,QAAQ,MAAM,KAAA,KACtB,WAAW,SAAS,SAAS,QAAQ,MACvC,SAAS,cAAc,CAAC,CAAC,MAAM,WAAW,IAAI,KAC9C,SAAS,cAAc,CAAC,CAAC,MAAM,WAAW,IAAI;CAElD;CAEA,YACE,UACA,OACS;EACT,OACE,SAAS,cAAc,CAAC,CAAC,MAAM,MAAM,IAAI,MACxC,MAAM,YAAY,KAAA,KACjB,SAAS,iBAAiB,CAAC,CAAC,MAAM,MAAM,OAAO,OAChD,MAAM,cAAc,KAAA,KACnB,SAAS,mBAAmB,CAAC,CAAC,MAAM,MAAM,SAAS;CAEzD;AACF"}