MCPcopy Create free account
hub / github.com/apache/skywalking-nodejs / interceptOperation

Method interceptOperation

src/plugins/IORedisPlugin.ts:37–65  ·  view source on GitHub ↗
(Cls: any, operation: string)

Source from the content-addressed store, hash-verified

35 }
36
37 interceptOperation(Cls: any, operation: string): void {
38 const _original = Cls.prototype[operation];
39
40 if (!_original) return;
41
42 Cls.prototype[operation] = function (...args: any[]) {
43 const command = args[0];
44 const host = `${this.options.host}:${this.options.port}`;
45 const span = ContextManager.current.newExitSpan(`redis/${command?.name}`, Component.REDIS);
46
47 span.start();
48 span.component = Component.REDIS;
49 span.layer = SpanLayer.CACHE;
50 span.peer = host;
51 span.tag(Tag.dbType('Redis'));
52 span.tag(Tag.dbInstance(`${this.condition?.select ?? host}`));
53
54 try {
55 const ret = wrapPromise(span, _original.apply(this, args));
56 span.async();
57 return ret;
58 } catch (err) {
59 span.error(err);
60 span.stop();
61
62 throw err;
63 }
64 };
65 }
66}
67
68export default new IORedisPlugin();

Callers 1

installMethod · 0.95

Calls 6

wrapPromiseFunction · 0.90
errorMethod · 0.80
newExitSpanMethod · 0.65
startMethod · 0.65
asyncMethod · 0.65
stopMethod · 0.65

Tested by

no test coverage detected