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ClC,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;SACrE;IACH,CAAC;IAEO,oBAAoB,CAC1B,IAAU,EACV,WAAmB,EACnB,WAAmC,EACnC,QAAiB,EACjB,KAAwB;QAExB,MAAM,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,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC;SACzE;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;;AAlbH,oDAmbC;AAlbiB,8BAAS,GAAG,OAAO,CAAC","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} from '@opentelemetry/instrumentation';\nimport { getClientAttributes } from './utils';\nimport { defaultDbStatementSerializer } from '@opentelemetry/redis-common';\nimport { RedisInstrumentationConfig } from './types';\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions';\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\nconst DEFAULT_CONFIG: RedisInstrumentationConfig = {\n requireParentSpan: false,\n};\n\nexport class RedisInstrumentation extends InstrumentationBase {\n static readonly COMPONENT = 'redis';\n\n constructor(config: RedisInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\n }\n\n override setConfig(config: RedisInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\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'],\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()\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'],\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'],\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() {\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 'got non promise result when patching RedisClientMultiCommand.exec'\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);\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 redis multi command'\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);\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\n const attributes = getClientAttributes(plugin._diag, options);\n\n const span = plugin.tracer.startSpan(\n `${RedisInstrumentation.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(this._diag, clientOptions);\n\n try {\n const dbStatement = dbStatementSerializer(commandName, commandArgs);\n if (dbStatement != null) {\n attributes[SEMATTRS_DB_STATEMENT] = dbStatement;\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 `${RedisInstrumentation.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 ) {\n if (!openSpans) {\n return this._diag.error(\n 'cannot find open spans to end for redis multi command'\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 for (let i = 0; i < openSpans.length; i++) {\n const { span, commandName, commandArgs } = openSpans[i];\n const currCommandRes = replies[i];\n const [res, err] =\n currCommandRes instanceof Error\n ? [null, currCommandRes]\n : [currCommandRes, undefined];\n this._endSpanWithResponse(span, commandName, 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"]}