Skip to content

Instantly share code, notes, and snippets.

@sandfox
Last active November 16, 2017 08:03
Show Gist options
  • Select an option

  • Save sandfox/4cbe100181e5f3215e828f537c7f04af to your computer and use it in GitHub Desktop.

Select an option

Save sandfox/4cbe100181e5f3215e828f537c7f04af to your computer and use it in GitHub Desktop.
Jaeger open tracing stuff

Soo, this sort of works (things appear in the UI!). Turns out the docker run command we used from the example didn't expose enough ports to allow the terrible nodejs script I wrote to send data into the container. I also set the config in my script to always record spans rather than sampling a limited number.

  1. make a folder somewhere, in it save trace_gen.js and npm install jaeger-client in there too.

  2. Run a docker container that has the "backend" / collector stuff in it:

docker run -d -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \
  -p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 jaegertracing/all-in-one:latest
  1. start the trace generator using node trace_gen.js
  2. open http://localhost:16686/ in your browser. my-awesome-service should already appear in the service drop down. Click Find Traces at the bottom and stuff should appear!

notes stopping and starting the docker container will clear it and the UI of any data (you may also need to refresh the UI browser tab too.

var jaeger = require('jaeger-client');
// See schema https://github.com/jaegertracing/jaeger-client-node/blob/master/src/configuration.js#L37
var config = {
disable: false,
logger: console, // here because bug at https://github.com/jaegertracing/jaeger-client-node/blob/master/src/configuration.js#L97 where it should probably be options.logger
serviceName: 'my-awesome-service',
sampler: {
type: 'const',
param: 1
},
reporter: {
logSpans: true // this prints out debug-ish info to the console
}
};
var options = {
logger: console
}
var tracer = jaeger.initTracer(config, options);
setInterval(function(){
// create a spane called 'http_request'
var span = tracer.startSpan('http_request');
// add some arbtary data to it that will show up in the UI
span.log({'event': 'data_received', 'chunk_length': 5000});
// close the span!
setTimeout(function(){
span.finish();
}, 500)
}, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment