Skip to content

Commit

Permalink
chore: removing force flush (#916)
Browse files Browse the repository at this point in the history
Co-authored-by: Mayur Kale <mayurkale@google.com>
  • Loading branch information
obecny and mayurkale22 authored Apr 1, 2020
1 parent 3d26f82 commit 7719c91
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
3 changes: 2 additions & 1 deletion packages/opentelemetry-exporter-jaeger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"precompile": "tsc --version",
"version:update": "node ../../scripts/version-update.js",
"compile": "npm run version:update && tsc -p .",
"prepare": "npm run compile"
"prepare": "npm run compile",
"watch": "tsc -w"
},
"keywords": [
"opentelemetry",
Expand Down
4 changes: 0 additions & 4 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ export class JaegerExporter implements SpanExporter {
private readonly _logger: api.Logger;
private readonly _process: jaegerTypes.ThriftProcess;
private readonly _sender: typeof jaegerTypes.UDPSender;
private readonly _forceFlushOnShutdown: boolean = true;
private readonly _onShutdownFlushTimeout: number;

constructor(config: jaegerTypes.ExporterConfig) {
this._logger = config.logger || new NoopLogger();
const tags: jaegerTypes.Tag[] = config.tags || [];
this._forceFlushOnShutdown =
typeof config.forceFlush === 'boolean' ? config.forceFlush : true;
this._onShutdownFlushTimeout =
typeof config.flushTimeout === 'number' ? config.flushTimeout : 2000;

Expand Down Expand Up @@ -69,7 +66,6 @@ export class JaegerExporter implements SpanExporter {

/** Shutdown exporter. */
shutdown(): void {
if (!this._forceFlushOnShutdown) return;
// Make an optimistic flush.
this._flush();
// Sleeping x seconds before closing the sender's connection to ensure
Expand Down
2 changes: 0 additions & 2 deletions packages/opentelemetry-exporter-jaeger/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export interface ExporterConfig {
host?: string; // default: 'localhost'
port?: number; // default: 6832
maxPacketSize?: number; // default: 65000
/** Force a flush on shutdown */
forceFlush?: boolean; // default: true
/** Time to wait for an onShutdown flush to finish before closing the sender */
flushTimeout?: number; // default: 2000
}
Expand Down
18 changes: 2 additions & 16 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,26 @@ describe('JaegerExporter', () => {
assert.strictEqual(process.tags[0].vStr, '0.1.0');
});

it('should construct an exporter with forceFlush and flushTimeout', () => {
it('should construct an exporter with flushTimeout', () => {
const exporter = new JaegerExporter({
serviceName: 'opentelemetry',
forceFlush: true,
flushTimeout: 5000,
});
assert.ok(typeof exporter.export === 'function');
assert.ok(typeof exporter.shutdown === 'function');

assert.ok(exporter['_forceFlushOnShutdown']);
assert.strictEqual(exporter['_onShutdownFlushTimeout'], 5000);
});

it('should construct an exporter without forceFlush and flushTimeout', () => {
it('should construct an exporter without flushTimeout', () => {
const exporter = new JaegerExporter({
serviceName: 'opentelemetry',
});
assert.ok(typeof exporter.export === 'function');
assert.ok(typeof exporter.shutdown === 'function');

assert.ok(exporter['_forceFlushOnShutdown']);
assert.strictEqual(exporter['_onShutdownFlushTimeout'], 2000);
});

it('should construct an exporter with forceFlush = false', () => {
const exporter = new JaegerExporter({
serviceName: 'opentelemetry',
forceFlush: false,
});
assert.ok(typeof exporter.export === 'function');
assert.ok(typeof exporter.shutdown === 'function');

assert.ok(!exporter['_forceFlushOnShutdown']);
});
});

describe('export', () => {
Expand Down

0 comments on commit 7719c91

Please sign in to comment.