You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/05/18 11:19:23 UTC

[GitHub] [skywalking-nodejs] tianyk opened a new pull request #53: Add ioredis plugin

tianyk opened a new pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53


   Add [ioredis](https://www.npmjs.com/package/ioredis) plugin.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 merged pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 merged pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] tianyk commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
tianyk commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-846490018


   Okay, I've resolved the conflict. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-843751603


   @tianyk can you please fix the CI ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-846546614


   Oops, one more thing. Can you update [the doc](https://github.com/apache/skywalking-nodejs#supported-libraries), including mysql2


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-845534736


   Hi @tianyk , since I merged #54 , there is conflicts, can you rebase and fix the conflicts? Thanks. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-846492479


   Tests failed because we have #52, can you adjust the expected.data.yaml?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-843088208


   Thanks. Please add test for the plugin. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-844175636


   Still, tests failed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] kezhenxu94 commented on a change in pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#discussion_r637507639



##########
File path: src/plugins/IORedisPlugin.ts
##########
@@ -0,0 +1,62 @@
+/*!
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import PluginInstaller from '../core/PluginInstaller';
+import SwPlugin, { wrapPromise } from '../core/SwPlugin';
+import { SpanLayer } from '../proto/language-agent/Tracing_pb';
+import Tag from '../Tag';
+import { Component } from '../trace/Component';
+import ContextManager from '../trace/context/ContextManager';
+
+class IORedisPlugin implements SwPlugin {
+	readonly module = 'ioredis';
+	readonly versions = '*';
+
+	install(installer: PluginInstaller): void {
+		const Redis = installer.require('ioredis');
+
+		this.interceptOperation(Redis, 'sendCommand');
+	}
+
+	interceptOperation(Cls: any, operation: string): void {
+		const _original = Cls.prototype[operation];
+
+		if (!_original)
+			return;
+
+		Cls.prototype[operation] = function (...args: any[]) {
+			const command = args[0];
+			const host = `${this.options.host}:${this.options.port}`;
+			const span = ContextManager.current.newExitSpan(`redis/${command?.name}`, Component.REDIS);
+
+			span.start();
+			span.component = Component.REDIS;
+			span.layer = SpanLayer.CACHE;
+			span.peer = host;
+			span.tag(Tag.cacheType('Redis'));
+			span.tag(Tag.cacheInstance(`${this.condition.select}`));

Review comment:
       Hi @tianyk , in other language agents (such as JAVA), we use `db.type` and `db.instance` for Redis instead of introducing a new tag `cache.type` and `cache.instance`, can you just reuse those tags to make them consistent across language agents?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nodejs] tianyk commented on pull request #53: Add ioredis plugin

Posted by GitBox <gi...@apache.org>.
tianyk commented on pull request #53:
URL: https://github.com/apache/skywalking-nodejs/pull/53#issuecomment-845268934


   I've fixed the CI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org