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EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,IAAI,YAAY,EAAE;YAC1B,IAAI;gBACF,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;aACxD;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;aAC1D;SACF;QACD,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,oBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;SACzE;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;;AAteU,8DAAyB","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 {\n trace,\n context,\n SpanKind,\n Span,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { getClientAttributes } from './utils';\nimport { defaultDbStatementSerializer } from '@opentelemetry/redis-common';\nimport { RedisInstrumentationConfig } from '../types';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from '../version';\nimport {\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_DB_STATEMENT } from '../semconv';\nimport type { MultiErrorReply } from './internal-types';\n\nconst OTEL_OPEN_SPANS = Symbol(\n 'opentelemetry.instrumentation.redis.open_spans'\n);\nconst MULTI_COMMAND_OPTIONS = Symbol(\n 'opentelemetry.instrumentation.redis.multi_command_options'\n);\n\ninterface MutliCommandInfo {\n span: Span;\n commandName: string;\n commandArgs: Array;\n}\n\nexport class RedisInstrumentationV4_V5 extends InstrumentationBase {\n static readonly COMPONENT = 'redis';\n private _semconvStability: SemconvStability;\n\n constructor(config: RedisInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this._semconvStability = config.semconvStability\n ? config.semconvStability\n : semconvStabilityFromStr(\n 'database',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n override setConfig(config: RedisInstrumentationConfig = {}) {\n super.setConfig(config);\n this._semconvStability = config.semconvStability\n ? config.semconvStability\n : semconvStabilityFromStr(\n 'database',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n protected init() {\n // @node-redis/client is a new package introduced and consumed by 'redis 4.0.x'\n // on redis@4.1.0 it was changed to @redis/client.\n // we will instrument both packages\n return [\n this._getInstrumentationNodeModuleDefinition('@redis/client'),\n this._getInstrumentationNodeModuleDefinition('@node-redis/client'),\n ];\n }\n\n private _getInstrumentationNodeModuleDefinition(\n basePackageName: string\n ): InstrumentationNodeModuleDefinition {\n const commanderModuleFile = new InstrumentationNodeModuleFile(\n `${basePackageName}/dist/lib/commander.js`,\n ['^1.0.0'],\n (moduleExports: any, moduleVersion?: string) => {\n const transformCommandArguments =\n moduleExports.transformCommandArguments;\n if (!transformCommandArguments) {\n this._diag.error(\n 'internal instrumentation error, missing transformCommandArguments function'\n );\n return moduleExports;\n }\n\n // function name and signature changed in redis 4.1.0 from 'extendWithCommands' to 'attachCommands'\n // the matching internal package names starts with 1.0.x (for redis 4.0.x)\n const functionToPatch = moduleVersion?.startsWith('1.0.')\n ? 'extendWithCommands'\n : 'attachCommands';\n // this is the function that extend a redis client with a list of commands.\n // the function patches the commandExecutor to record a span\n if (isWrapped(moduleExports?.[functionToPatch])) {\n this._unwrap(moduleExports, functionToPatch);\n }\n this._wrap(\n moduleExports,\n functionToPatch,\n this._getPatchExtendWithCommands(transformCommandArguments)\n );\n\n return moduleExports;\n },\n (moduleExports: any) => {\n if (isWrapped(moduleExports?.extendWithCommands)) {\n this._unwrap(moduleExports, 'extendWithCommands');\n }\n if (isWrapped(moduleExports?.attachCommands)) {\n this._unwrap(moduleExports, 'attachCommands');\n }\n }\n );\n\n const multiCommanderModule = new InstrumentationNodeModuleFile(\n `${basePackageName}/dist/lib/client/multi-command.js`,\n ['^1.0.0', '^5.0.0'],\n (moduleExports: any) => {\n const redisClientMultiCommandPrototype =\n moduleExports?.default?.prototype;\n\n if (isWrapped(redisClientMultiCommandPrototype?.exec)) {\n this._unwrap(redisClientMultiCommandPrototype, 'exec');\n }\n this._wrap(\n redisClientMultiCommandPrototype,\n 'exec',\n this._getPatchMultiCommandsExec(false)\n );\n if (isWrapped(redisClientMultiCommandPrototype?.execAsPipeline)) {\n this._unwrap(redisClientMultiCommandPrototype, 'execAsPipeline');\n }\n this._wrap(\n redisClientMultiCommandPrototype,\n 'execAsPipeline',\n this._getPatchMultiCommandsExec(true)\n );\n\n if (isWrapped(redisClientMultiCommandPrototype?.addCommand)) {\n this._unwrap(redisClientMultiCommandPrototype, 'addCommand');\n }\n this._wrap(\n redisClientMultiCommandPrototype,\n 'addCommand',\n this._getPatchMultiCommandsAddCommand()\n );\n\n return moduleExports;\n },\n (moduleExports: any) => {\n const redisClientMultiCommandPrototype =\n moduleExports?.default?.prototype;\n if (isWrapped(redisClientMultiCommandPrototype?.exec)) {\n this._unwrap(redisClientMultiCommandPrototype, 'exec');\n }\n if (isWrapped(redisClientMultiCommandPrototype?.addCommand)) {\n this._unwrap(redisClientMultiCommandPrototype, 'addCommand');\n }\n }\n );\n\n const clientIndexModule = new InstrumentationNodeModuleFile(\n `${basePackageName}/dist/lib/client/index.js`,\n ['^1.0.0', '^5.0.0'],\n (moduleExports: any) => {\n const redisClientPrototype = moduleExports?.default?.prototype;\n\n // In some @redis/client versions 'multi' is a method. In later\n // versions, as of https://github.com/redis/node-redis/pull/2324,\n // 'MULTI' is a method and 'multi' is a property defined in the\n // constructor that points to 'MULTI', and therefore it will not\n // be defined on the prototype.\n if (redisClientPrototype?.multi) {\n if (isWrapped(redisClientPrototype?.multi)) {\n this._unwrap(redisClientPrototype, 'multi');\n }\n this._wrap(\n redisClientPrototype,\n 'multi',\n this._getPatchRedisClientMulti()\n );\n }\n if (redisClientPrototype?.MULTI) {\n if (isWrapped(redisClientPrototype?.MULTI)) {\n this._unwrap(redisClientPrototype, 'MULTI');\n }\n this._wrap(\n redisClientPrototype,\n 'MULTI',\n this._getPatchRedisClientMulti()\n );\n }\n\n if (isWrapped(redisClientPrototype?.sendCommand)) {\n this._unwrap(redisClientPrototype, 'sendCommand');\n }\n this._wrap(\n redisClientPrototype,\n 'sendCommand',\n this._getPatchRedisClientSendCommand()\n );\n\n this._wrap(\n redisClientPrototype,\n 'connect',\n this._getPatchedClientConnect()\n );\n\n return moduleExports;\n },\n (moduleExports: any) => {\n const redisClientPrototype = moduleExports?.default?.prototype;\n if (isWrapped(redisClientPrototype?.multi)) {\n this._unwrap(redisClientPrototype, 'multi');\n }\n if (isWrapped(redisClientPrototype?.MULTI)) {\n this._unwrap(redisClientPrototype, 'MULTI');\n }\n if (isWrapped(redisClientPrototype?.sendCommand)) {\n this._unwrap(redisClientPrototype, 'sendCommand');\n }\n }\n );\n\n return new InstrumentationNodeModuleDefinition(\n basePackageName,\n ['^1.0.0', '^5.0.0'],\n (moduleExports: any) => {\n return moduleExports;\n },\n () => {},\n [commanderModuleFile, multiCommanderModule, clientIndexModule]\n );\n }\n\n // serves both for redis 4.0.x where function name is extendWithCommands\n // and redis ^4.1.0 where function name is attachCommands\n private _getPatchExtendWithCommands(transformCommandArguments: Function) {\n const plugin = this;\n return function extendWithCommandsPatchWrapper(original: Function) {\n return function extendWithCommandsPatch(this: any, config: any) {\n if (config?.BaseClass?.name !== 'RedisClient') {\n return original.apply(this, arguments);\n }\n\n const origExecutor = config.executor;\n config.executor = function (\n this: any,\n command: any,\n args: Array\n ) {\n const redisCommandArguments = transformCommandArguments(\n command,\n args\n ).args;\n return plugin._traceClientCommand(\n origExecutor,\n this,\n arguments,\n redisCommandArguments\n );\n };\n return original.apply(this, arguments);\n };\n };\n }\n\n private _getPatchMultiCommandsExec(isPipeline: boolean) {\n const plugin = this;\n return function execPatchWrapper(original: Function) {\n return function execPatch(this: any) {\n const execRes = original.apply(this, arguments);\n if (typeof execRes?.then !== 'function') {\n plugin._diag.error(\n 'non-promise result when patching exec/execAsPipeline'\n );\n return execRes;\n }\n\n return execRes\n .then((redisRes: unknown[]) => {\n const openSpans = this[OTEL_OPEN_SPANS];\n plugin._endSpansWithRedisReplies(openSpans, redisRes, isPipeline);\n return redisRes;\n })\n .catch((err: Error) => {\n const openSpans = this[OTEL_OPEN_SPANS];\n if (!openSpans) {\n plugin._diag.error(\n 'cannot find open spans to end for multi/pipeline'\n );\n } else {\n const replies =\n err.constructor.name === 'MultiErrorReply'\n ? (err as MultiErrorReply).replies\n : new Array(openSpans.length).fill(err);\n plugin._endSpansWithRedisReplies(openSpans, replies, isPipeline);\n }\n return Promise.reject(err);\n });\n };\n };\n }\n\n private _getPatchMultiCommandsAddCommand() {\n const plugin = this;\n return function addCommandWrapper(original: Function) {\n return function addCommandPatch(this: any, args: Array) {\n return plugin._traceClientCommand(original, this, arguments, args);\n };\n };\n }\n\n private _getPatchRedisClientMulti() {\n return function multiPatchWrapper(original: Function) {\n return function multiPatch(this: any) {\n const multiRes = original.apply(this, arguments);\n multiRes[MULTI_COMMAND_OPTIONS] = this.options;\n return multiRes;\n };\n };\n }\n\n private _getPatchRedisClientSendCommand() {\n const plugin = this;\n return function sendCommandWrapper(original: Function) {\n return function sendCommandPatch(\n this: any,\n args: Array\n ) {\n return plugin._traceClientCommand(original, this, arguments, args);\n };\n };\n }\n\n private _getPatchedClientConnect() {\n const plugin = this;\n return function connectWrapper(original: Function) {\n return function patchedConnect(this: any): Promise {\n const options = this.options;\n const attributes = getClientAttributes(\n plugin._diag,\n options,\n plugin._semconvStability\n );\n\n const span = plugin.tracer.startSpan(\n `${RedisInstrumentationV4_V5.COMPONENT}-connect`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n }\n );\n\n const res = context.with(trace.setSpan(context.active(), span), () => {\n return original.apply(this);\n });\n\n return res\n .then((result: unknown) => {\n span.end();\n return result;\n })\n .catch((error: Error) => {\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.end();\n return Promise.reject(error);\n });\n };\n };\n }\n\n private _traceClientCommand(\n origFunction: Function,\n origThis: any,\n origArguments: IArguments,\n redisCommandArguments: Array\n ) {\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (hasNoParentSpan && this.getConfig().requireParentSpan) {\n return origFunction.apply(origThis, origArguments);\n }\n\n const clientOptions = origThis.options || origThis[MULTI_COMMAND_OPTIONS];\n\n const commandName = redisCommandArguments[0] as string; // types also allows it to be a Buffer, but in practice it only string\n const commandArgs = redisCommandArguments.slice(1);\n\n const dbStatementSerializer =\n this.getConfig().dbStatementSerializer || defaultDbStatementSerializer;\n\n const attributes = getClientAttributes(\n this._diag,\n clientOptions,\n this._semconvStability\n );\n if (this._semconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_OPERATION_NAME] = commandName;\n }\n try {\n const dbStatement = dbStatementSerializer(commandName, commandArgs);\n if (dbStatement != null) {\n if (this._semconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_STATEMENT] = dbStatement;\n }\n if (this._semconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_QUERY_TEXT] = dbStatement;\n }\n }\n } catch (e) {\n this._diag.error('dbStatementSerializer throw an exception', e, {\n commandName,\n });\n }\n\n const span = this.tracer.startSpan(\n `${RedisInstrumentationV4_V5.COMPONENT}-${commandName}`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n }\n );\n\n const res = context.with(trace.setSpan(context.active(), span), () => {\n return origFunction.apply(origThis, origArguments);\n });\n if (typeof res?.then === 'function') {\n res.then(\n (redisRes: unknown) => {\n this._endSpanWithResponse(\n span,\n commandName,\n commandArgs,\n redisRes,\n undefined\n );\n },\n (err: any) => {\n this._endSpanWithResponse(span, commandName, commandArgs, null, err);\n }\n );\n } else {\n const redisClientMultiCommand = res as {\n [OTEL_OPEN_SPANS]?: Array;\n };\n redisClientMultiCommand[OTEL_OPEN_SPANS] =\n redisClientMultiCommand[OTEL_OPEN_SPANS] || [];\n redisClientMultiCommand[OTEL_OPEN_SPANS]!.push({\n span,\n commandName,\n commandArgs,\n });\n }\n return res;\n }\n\n private _endSpansWithRedisReplies(\n openSpans: Array,\n replies: unknown[],\n isPipeline = false\n ) {\n if (!openSpans) {\n return this._diag.error(\n 'cannot find open spans to end for redis multi/pipeline'\n );\n }\n if (replies.length !== openSpans.length) {\n return this._diag.error(\n 'number of multi command spans does not match response from redis'\n );\n }\n // Determine a single operation name for the batch of commands.\n // If all commands are identical, include the command name (e.g., \"MULTI SET\").\n // Otherwise, use a generic \"MULTI\" or \"PIPELINE\" label for the span.\n const allCommands = openSpans.map(s => s.commandName);\n const allSameCommand = allCommands.every(cmd => cmd === allCommands[0]);\n const operationName = allSameCommand\n ? (isPipeline ? 'PIPELINE ' : 'MULTI ') + allCommands[0]\n : isPipeline\n ? 'PIPELINE'\n : 'MULTI';\n\n for (let i = 0; i < openSpans.length; i++) {\n const { span, commandArgs } = openSpans[i];\n const currCommandRes = replies[i];\n const [res, err] =\n currCommandRes instanceof Error\n ? [null, currCommandRes]\n : [currCommandRes, undefined];\n\n if (this._semconvStability & SemconvStability.STABLE) {\n span.setAttribute(ATTR_DB_OPERATION_NAME, operationName);\n }\n\n this._endSpanWithResponse(span, allCommands[i], commandArgs, res, err);\n }\n }\n\n private _endSpanWithResponse(\n span: Span,\n commandName: string,\n commandArgs: Array,\n response: unknown,\n error: Error | undefined\n ) {\n const { responseHook } = this.getConfig();\n if (!error && responseHook) {\n try {\n responseHook(span, commandName, commandArgs, response);\n } catch (err) {\n this._diag.error('responseHook throw an exception', err);\n }\n }\n if (error) {\n span.recordException(error);\n span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });\n }\n span.end();\n }\n}\n"]}