Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
support v3 protocol (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascrutae committed Aug 2, 2020
1 parent 099adcf commit 61d6b64
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 137 deletions.
2 changes: 1 addition & 1 deletion docs/compatibility-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ So you have two ways to resolve this problem. One is **download the compatible v
| 0.1.x | 5.0.0-beta |
| 0.3.0 | 5.0.0-RC |
| 1.0.0 | 6.0.0-GA |
| 2.0.0 | 8.0.0 |
| 2.0.0 | 8.1.0 |


## Add your own component library
Expand Down
34 changes: 34 additions & 0 deletions modules/nodejs-agent/examples/cross-app/cross-serverA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require("skyapm-nodejs").start({
serviceName: 'testA',
instanceName: 'testA',
directServers: 'localhost:11800'
});

let http = require('http');
let server = http.createServer(function (req, res) { //create web server
const options = {
hostname: 'localhost',
port: 5002,
path: '/serverB',
method: 'GET'
}

const newReq = http.request(options, newRes => {
console.log(`statusCode: ${res.statusCode}`)
newRes.on('data', d => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(d);
res.end();
})
})

newReq.on('error', error => {
throw error
})

newReq.end()

});

server.listen(5001);
console.log('Node.js web server at port 5000 is running..')
30 changes: 30 additions & 0 deletions modules/nodejs-agent/examples/cross-app/cross-serverB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require("skyapm-nodejs").start({
serviceName: 'testB',
instanceName: 'testB',
directServers: 'localhost:11800'
});

let http = require('http');
let mysql = require("mysql");

let server = http.createServer(function (req, res) { //create web server
let connection = mysql.createConnection({
host: "localhost",
port: 3306,
user: "root",
password: "root1234",
database: "test_database",
});

connection.connect();

connection.query("SELECT SLEEP(1)", function (error, results, fields) {
if (error) throw error;
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<html><body><p>This is student Page.</p></body></html>');
res.end();
});
});

server.listen(5002);
console.log('Node.js web server at port 5000 is running..')
55 changes: 0 additions & 55 deletions modules/nodejs-agent/examples/cross-app/serverA.js

This file was deleted.

70 changes: 0 additions & 70 deletions modules/nodejs-agent/examples/cross-app/serverB.js

This file was deleted.

6 changes: 3 additions & 3 deletions modules/nodejs-agent/lib/trace/context-carrier.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ ContextCarrier.prototype.serialize = function() {
traceContextArray.push(Base64.encode(this._traceId));
traceContextArray.push(Base64.encode(this._traceSegmentId));
traceContextArray.push(this._spanId);
traceContextArray.push(Base64.encode(this._parentService));
traceContextArray.push(Base64.encode(this._parentServiceInstance));
traceContextArray.push(this._parentService);
traceContextArray.push(this._parentServiceInstance);
traceContextArray.push(Base64.encode(this._parentEndpoint));
traceContextArray.push(Base64.encode(this._addressUsedAtClient));
return traceContextArray.join("-");
Expand All @@ -53,7 +53,7 @@ ContextCarrier.prototype.deserialize = function(traceContext) {
}

let traceContextSegment = traceContext.split("-");
if (traceContextSegment.length !== 8) {
if (traceContextSegment.length != 8) {
return this;
}

Expand Down
9 changes: 2 additions & 7 deletions modules/nodejs-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"generate-source": "run-script-os",
"generate-source:win32": "rd lib/network && md lib/network && cd proto && grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../lib/network/ --grpc_out=../lib/network/ common/*.proto language-agent/Tracing.proto management/*.proto",
"generate-source:darwin:linux": "rm -rf lib/network && mkdir -p lib/network && cd proto && grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../lib/network/ --grpc_out=../lib/network/ common/*.proto language-agent/Tracing.proto management/*.proto",
"check": "eslint lib/ && eslint index.js",
"test": "mocha test/**/*.test.js --recursive"
"check": "eslint lib/ && eslint index.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,18 +46,14 @@
"semver": "^5.5.1"
},
"devDependencies": {
"axios": "^0.19.2",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"eslint-plugin-header": "^1.2.0",
"grpc-tools": "1.7.1",
"mocha": "^7.2.0",
"mysql": "^2.15.0",
"require-self": "^0.2.1",
"run-script-os": "^1.0.3",
"wait-until": "0.0.2",
"yaml": "^1.10.0"
"run-script-os": "^1.0.3"
},
"eslintIgnore": [
"lib/network/common/*.js",
Expand Down

0 comments on commit 61d6b64

Please sign in to comment.