Skip to content

Commit

Permalink
HWKAPM-689 | reproducer for missing client spans from nodejs app
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolloffay committed Oct 13, 2016
1 parent 8fe7516 commit 9bc8b26
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/polyglot-zipkin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ image::zipkin-createUser.png[Zipkin UI, createUser, height="300", width="800"]

== Known issues
* https://issues.jboss.org/browse/HWKAPM-623[Span from ruby app fail to deserialize in zipkin server]
* https://issues.jboss.org/browse/HWKAPM-689[zipkin-js instrumentation does not send all client spans]
33 changes: 31 additions & 2 deletions examples/polyglot-zipkin/js-express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const http = require('http');
const {HttpLogger} = require('zipkin-transport-http');
const rest = require('rest');
const mime = require('rest/interceptor/mime');
const bodyParser = require('body-parser')
const bodyParser = require('body-parser');

const zipkin = require('zipkin');
const {restInterceptor} = require('zipkin-instrumentation-cujojs-rest');
Expand Down Expand Up @@ -66,7 +66,7 @@ app.post(apiPrefix + '/createUser', function (req, resp) {
postData(user, 'http://wildfy-swarm:3003/wildfly-swarm/users');

console.log('User: ', user, " created!");
resp.send("Users created!");
resp.send('Users created!');
});

function postData(user, url) {
Expand All @@ -81,6 +81,35 @@ function postData(user, url) {
});
}

/**
* Reproducer for https://github.com/openzipkin/zipkin-js/issues/32
* Some client spans are not being reported.
*
* Execute multiple times:
* curl -ivX GET 'http://localhost:3001/nodejs/clientSpans?n=50'
*
* Server should show 1 + n reported spans (1 server span and n client spans)
*/
app.get(apiPrefix + '/clientSpans', function (req, resp) {

let url = 'https://jsonplaceholder.typicode.com/posts/1';
let numberOfRequests = req.query.n;

for (let i = 0; i < numberOfRequests; i++) {
client({
method: 'GET',
path: url,
entity: 'some data'
}).then(success => {
console.log('Got ' + i + ' successful response from ' + url);
}, error => {
console.error('Error', error);
});
}

resp.send(numberOfRequests + ' requests to ' + url);
});

var server = app.listen(3001, '0.0.0.0', function() {
var host = server.address().address;
var port = server.address().port;
Expand Down

0 comments on commit 9bc8b26

Please sign in to comment.