Skip to content

Commit

Permalink
fix(jaeger): assign correct scope for flush operation (open-telemetry…
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored and bg451 committed Sep 30, 2019
1 parent f82a2d8 commit b0f3d3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 6 additions & 0 deletions examples/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ function makeRequest() {
});
});
})

// The process must live for at least the interval past any traces that
// must be exported, or some risk being lost if they are recorded after the
// last export.
console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.')
setTimeout(() => { console.log('Completed.'); }, 5000);
}

makeRequest();
19 changes: 11 additions & 8 deletions examples/http/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
let exporter;
const options = {
serviceName: service,
}
const tracer = new NodeTracer();


let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter(options);
exporter = new ZipkinExporter({
serviceName: service,
});
} else {
exporter = new JaegerExporter(options);
exporter = new JaegerExporter({
serviceName: service,
// The default flush interval is 5 seconds.
flushInterval: 2000
});
}

tracer.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class JaegerExporter implements SpanExporter {
this._sender.setProcess(this._process);

const flushInterval = config.flushInterval || 5000;
this._timer = setInterval(this._flush, flushInterval);
this._timer = setInterval(this._flush.bind(this), flushInterval);
unrefTimer(this._timer);
}

Expand Down

0 comments on commit b0f3d3e

Please sign in to comment.