openzipkin/zipkin-js
GitHub で見るzipkin-instrumentation-redis will throw error if not set callback
Open
#194 opened on 2018年3月6日
help wanted
Repository metrics
- Stars
- (569 stars)
- PR merge metrics
- (PR metrics pending)
説明
If I didn't set callback when execute redis command like del, will throw a error as below.
Record at (spanId=be186f731a57d3d5, parentId=be186f731a57d3d5, traceId=be186f731a57d3d5): Rpc("del")
Record at (spanId=be186f731a57d3d5, parentId=be186f731a57d3d5, traceId=be186f731a57d3d5): ServiceName("test")
Record at (spanId=be186f731a57d3d5, parentId=be186f731a57d3d5, traceId=be186f731a57d3d5): ServerAddr(serviceName="redis", host="InetAddress(undefined)", port=0)
Record at (spanId=be186f731a57d3d5, parentId=be186f731a57d3d5, traceId=be186f731a57d3d5): ClientSend()
Record at (spanId=be186f731a57d3d5, parentId=be186f731a57d3d5, traceId=be186f731a57d3d5): ClientRecv()
/Library/WebServer/projects/qr-wap-pay/node_modules/continuation-local-storage/context.js:55
throw exception;
^
TypeError: callback.apply is not a function
at /Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-instrumentation-redis/lib/zipkinClient.js:31:18
at /Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-context-cls/lib/CLSContext.js:53:16
at /Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-context-cls/lib/CLSContext.js:42:18
at Namespace.run (/Library/WebServer/projects/qr-wap-pay/node_modules/continuation-local-storage/context.js:48:5)
at CLSContext.scoped (/Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-context-cls/lib/CLSContext.js:41:21)
at CLSContext.letContext (/Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-context-cls/lib/CLSContext.js:51:19)
at Tracer.letId (/Library/WebServer/projects/qr-wap-pay/node_modules/zipkin/lib/tracer/index.js:73:28)
at zipkinCallback (/Library/WebServer/projects/qr-wap-pay/node_modules/zipkin-instrumentation-redis/lib/zipkinClient.js:30:14)
at Object.callbackOrEmit [as callback_or_emit] (/Library/WebServer/projects/qr-wap-pay/node_modules/redis/lib/utils.js:89:9)
at RedisClient.return_error (/Library/WebServer/projects/qr-wap-pay/node_modules/redis/index.js:701:11)
test code:
const zipkin = require('zipkin');
const CLSContext = require('zipkin-context-cls');
const Redis = require('redis');
const zipkinClient = require('zipkin-instrumentation-redis');
const ctxImpl = new CLSContext('zipkin');
const tracer = new zipkin.Tracer({
ctxImpl,
recorder: new zipkin.ConsoleRecorder(),
localServiceName: 'test',
});
const redis = zipkinClient(tracer, Redis, {});
redis.del('test');
If should judgment the callback is set or not before apply callback ?