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AC,oBAAoB,CAAC,oBAAoB,EAAE;YACnD,GAAG,IAAI,CAAC,oBAAoB,CAAC,oBAAoB,EAAE;SACpD,CAAC;IACJ,CAAC;IAEQ,iBAAiB,CAAC,cAA8B;QACvD,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO;SACR;QACD,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAC5D,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;IAEQ,MAAM;QACb,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO;SACR;QACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAEQ,OAAO;QACd,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO;SACR;QACD,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACF;AAjED,oDAiEC","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 */\nimport {\n InstrumentationBase,\n InstrumentationModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport { RedisInstrumentationConfig } from './types';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { RedisInstrumentationV2_V3 } from './v2-v3/instrumentation';\nimport { TracerProvider } from '@opentelemetry/api';\nimport { RedisInstrumentationV4_V5 } from './v4-v5/instrumentation';\n\nconst DEFAULT_CONFIG: RedisInstrumentationConfig = {\n requireParentSpan: false,\n};\n\n// Wrapper RedisInstrumentation that address all supported versions\nexport class RedisInstrumentation extends InstrumentationBase {\n private instrumentationV2_V3: RedisInstrumentationV2_V3;\n private instrumentationV4_V5: RedisInstrumentationV4_V5;\n\n // this is used to bypass a flaw in the base class constructor, which is calling\n // member functions before the constructor has a chance to fully initialize the member variables.\n private initialized = false;\n\n constructor(config: RedisInstrumentationConfig = {}) {\n const resolvedConfig = { ...DEFAULT_CONFIG, ...config };\n super(PACKAGE_NAME, PACKAGE_VERSION, resolvedConfig);\n\n this.instrumentationV2_V3 = new RedisInstrumentationV2_V3(this.getConfig());\n this.instrumentationV4_V5 = new RedisInstrumentationV4_V5(this.getConfig());\n this.initialized = true;\n }\n\n override setConfig(config: RedisInstrumentationConfig = {}) {\n const newConfig = { ...DEFAULT_CONFIG, ...config };\n super.setConfig(newConfig);\n if (!this.initialized) {\n return;\n }\n\n this.instrumentationV2_V3.setConfig(newConfig);\n this.instrumentationV4_V5.setConfig(newConfig);\n }\n\n override init() {}\n\n // Return underlying modules, as consumers (like https://github.com/DrewCorlin/opentelemetry-node-bundler-plugins) may\n // expect them to be populated without knowing that this module wraps 2 instrumentations\n override getModuleDefinitions(): InstrumentationModuleDefinition[] {\n return [\n ...this.instrumentationV2_V3.getModuleDefinitions(),\n ...this.instrumentationV4_V5.getModuleDefinitions(),\n ];\n }\n\n override setTracerProvider(tracerProvider: TracerProvider) {\n super.setTracerProvider(tracerProvider);\n if (!this.initialized) {\n return;\n }\n this.instrumentationV2_V3.setTracerProvider(tracerProvider);\n this.instrumentationV4_V5.setTracerProvider(tracerProvider);\n }\n\n override enable() {\n super.enable();\n if (!this.initialized) {\n return;\n }\n this.instrumentationV2_V3.enable();\n this.instrumentationV4_V5.enable();\n }\n\n override disable() {\n super.disable();\n if (!this.initialized) {\n return;\n }\n this.instrumentationV2_V3.disable();\n this.instrumentationV4_V5.disable();\n }\n}\n"]}