cloud-trace-nodejs
cloud-trace-nodejs copied to clipboard
Error with using redis and cloud-trace-nodejs
My env:
-
OS: containered node:12.8.0-alpine
-
Redis version: Google Cloud Platform Memorystore Redis 6.x
-
NodeJS version: 12.8.0
-
NPM version: 7.24.0
Package.json:
-
@google-cloud/trace-agent
: "^5.1.6" (also tested on 5.1.3) -
redis
: "^4.0.0"
How I init cloud-trace:
if (env.NODE_ENV === 'production') {
const serviceContext = {
service: pkg.name,
version: pkg.version,
}
require('@google-cloud/trace-agent').start({ serviceContext })
require('@google-cloud/debug-agent').start({ serviceContext })
}
After container started I see this error:
TypeError: Cannot read property 'prototype' of undefined
at wrapCreateStream (/var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/plugins/plugin-redis.js:145:36)
at Object.patch (/var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/plugins/plugin-redis.js:167:13)
at /var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/trace-plugin-loader.js:93:23
at Array.reduce (<anonymous>)
at ModulePluginWrapper.applyPlugin (/var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/trace-plugin-loader.js:87:33)
at /var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/trace-plugin-loader.js:278:64
at Module.Hook._require.Module.require (/var/lib/__HIDDEN__/node_modules/require-in-the-middle/index.js:154:32)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/var/lib/__HIDDEN__/service/redis.js:2:26)
at Module._compile (internal/modules/cjs/loader.js:868:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
at Module.load (internal/modules/cjs/loader.js:731:32)
at Function.Module._load (internal/modules/cjs/loader.js:644:12)
at Module.require (internal/modules/cjs/loader.js:771:19)
at Module.Hook._require.Module.require (/var/lib/__HIDDEN__/node_modules/require-in-the-middle/index.js:80:39)
at require (internal/modules/cjs/helpers.js:68:18)
/var/lib/__HIDDEN__/node_modules/@google-cloud/trace-agent/build/src/plugins/plugin-redis.js:145
shimmer.wrap(redis.RedisClient.prototype, 'create_stream', createCreateStreamWrap(api));
Questions:
- How can I disable redis plugin for cloud-trace-agent?
- Can you update the redis-plugin to support latest version of Redis and redis lib?
Hey team. Do you need any additional information from me?
Sorry for the delay in responding...
In terms of disabling the plugin, this can be done from the config: https://github.com/googleapis/cloud-trace-nodejs/blob/d5c7cfdefd47cf14d09668b3ee4f5d6e2d62f19f/src/config.ts#L171
/**
* A list of trace plugins to load. Each field's key in this object is the
* name of the module to trace, and its value is the require-friendly path
* to the plugin. (See the default configuration below for examples.)
* Any user-provided value will be used to extend its default value.
* To disable a plugin in this list, you may override its path with a falsy
* value. Disabling any of the default plugins may cause unwanted behavior,
* so use caution.
*/
plugins?: {[pluginName: string]: string};
Further down in that same file, you can see the defaultConfig
:
export const defaultConfig = {
// ...
plugins: {
// ...
redis: path.join(pluginDirectory, 'plugin-redis.js')
// ...
}
// ...
}
The request to fix this (and support the latest Redis) is reasonable, but I unfortunately cannot commit to any timeline here due to team capacity constraints. Our team can commit to reviewing pull requests, however. If that is not an option and if this is really, really important to you, escalating this through Cloud Support may help in terms of staffing and prioritization at a higher level.
We'll ensure that cloud-trace-nodejs won't error out when used in conjunction with redis v4+. However, we aren't able to prioritize building actual instrumentation support for redis v4+ at this time. Please consider using @opentelemetry/instrumentation-redis-4 instead.