Added http protocol to plugins (#28)

* Update expected.data.yaml

Co-authored-by: Zhenxu Ke <kezhenxu94@apache.org>
diff --git a/src/plugins/ExpressPlugin.ts b/src/plugins/ExpressPlugin.ts
index cd94ca3..5a550e3 100644
--- a/src/plugins/ExpressPlugin.ts
+++ b/src/plugins/ExpressPlugin.ts
@@ -76,7 +76,6 @@
           || (req.connection.remoteFamily === 'IPv6'
             ? `[${req.connection.remoteAddress}]:${req.connection.remotePort}`
             : `${req.connection.remoteAddress}:${req.connection.remotePort}`);
-        span.tag(Tag.httpURL((req.headers.host || '') + req.url));
         span.tag(Tag.httpMethod(req.method));
 
         const ret = _handle.call(this, req, res, (err: Error) => {
@@ -95,6 +94,8 @@
       } catch (e) {
         stopIfNotStopped(e);
         throw e;
+      } finally {  // req.protocol is only possibly available after call to _handle()
+        span.tag(Tag.httpURL(((req as any).protocol ? (req as any).protocol + '://' : '') + (req.headers.host || '') + req.url));
       }
     };
   }
diff --git a/src/plugins/HttpPlugin.ts b/src/plugins/HttpPlugin.ts
index 8c1e090..e324b00 100644
--- a/src/plugins/HttpPlugin.ts
+++ b/src/plugins/HttpPlugin.ts
@@ -38,9 +38,9 @@
     const https = require('https');
 
     this.interceptClientRequest(http);
-    this.interceptServerRequest(http);
+    this.interceptServerRequest(http, 'http');
     this.interceptClientRequest(https);
-    this.interceptServerRequest(https);
+    this.interceptServerRequest(https, 'https');
   }
 
   private interceptClientRequest(module: any) {
@@ -120,7 +120,7 @@
     };
   }
 
-  private interceptServerRequest(module: any) {
+  private interceptServerRequest(module: any, protocol: string) {
     /// TODO? full event protocol support not currently implemented (prependListener(), removeListener(), etc...)
     const _addListener = module.Server.prototype.addListener;
 
@@ -159,7 +159,7 @@
             || (req.connection.remoteFamily === 'IPv6'
               ? `[${req.connection.remoteAddress}]:${req.connection.remotePort}`
               : `${req.connection.remoteAddress}:${req.connection.remotePort}`);
-          span.tag(Tag.httpURL((req.headers.host || '') + req.url));
+          span.tag(Tag.httpURL(protocol + '://' + (req.headers.host || '') + req.url));
           span.tag(Tag.httpMethod(req.method));
 
           let ret = handler.call(this, req, res, ...reqArgs);
diff --git a/tests/plugins/axios/expected.data.yaml b/tests/plugins/axios/expected.data.yaml
index f5c66d3..ddb2fc9 100644
--- a/tests/plugins/axios/expected.data.yaml
+++ b/tests/plugins/axios/expected.data.yaml
@@ -54,7 +54,7 @@
             skipAnalysis: false
             tags:
               - key: http.url
-                value: server:5000/axios
+                value: http://server:5000/axios
               - key: http.method
                 value: GET
               - key: http.status.code
@@ -102,7 +102,7 @@
             spanLayer: Http
             tags:
               - key: http.url
-                value: localhost:5001/axios
+                value: http://localhost:5001/axios
               - key: http.method
                 value: GET
               - key: http.status.code
diff --git a/tests/plugins/express/expected.data.yaml b/tests/plugins/express/expected.data.yaml
index 23ba437..240a481 100644
--- a/tests/plugins/express/expected.data.yaml
+++ b/tests/plugins/express/expected.data.yaml
@@ -47,10 +47,10 @@
             spanId: 0
             spanLayer: Http
             tags:
-              - key: http.url
-                value: server:5000/express
               - key: http.method
                 value: GET
+              - key: http.url
+                value: http://server:5000/express
               - key: http.status.code
                 value: '200'
               - key: http.status.msg
@@ -101,10 +101,10 @@
             spanId: 0
             spanLayer: Http
             tags:
-              - key: http.url
-                value: localhost:5001/express
               - key: http.method
                 value: GET
+              - key: http.url
+                value: http://localhost:5001/express
               - key: http.status.code
                 value: '200'
               - key: http.status.msg
diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml
index b7e241d..486b6ce 100644
--- a/tests/plugins/http/expected.data.yaml
+++ b/tests/plugins/http/expected.data.yaml
@@ -34,7 +34,7 @@
             skipAnalysis: false
             tags:
               - key: http.url
-                value: server:5000/test
+                value: http://server:5000/test
               - key: http.method
                 value: GET
               - key: http.status.code
@@ -86,7 +86,7 @@
             skipAnalysis: false
             tags:
               - key: http.url
-                value: localhost:5001/test
+                value: http://localhost:5001/test
               - key: http.method
                 value: GET
               - key: http.status.code