Skip to content

Commit

Permalink
fix(jaeger-remote-sampler): Catch errors retrieving remote config (#4976
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Just-Sieb authored Sep 4, 2024
1 parent 9d474e3 commit a3983fa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(sampler-jaeger-remote): fixes an issue where package could emit unhandled promise rejections @Just-Sieb

### :books: (Refine Doc)

### :house: (Internal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class JaegerRemoteSampler implements Sampler {
this._syncingConfig = true;
try {
await this.getAndUpdateSampler();
} catch (err) {
diag.warn('Could not update sampler', err);
} finally {
this._syncingConfig = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,28 @@ describe('JaegerRemoteSampler', () => {
);
new JaegerRemoteSampler({
endpoint,
serviceName,
poolingInterval,
serviceName,
initialSampler: alwaysOnSampler,
});
await clock.tickAsync(poolingInterval * 2);
sinon.assert.callCount(getAndUpdateSamplerStub, 1);
});

it('Doesnt throw unhandled promise rejection when failing to get remote config', async () => {
getAndUpdateSamplerStub.rejects();
const unhandledRejectionListener = sinon.fake();
process.once('unhandledRejection', unhandledRejectionListener);
new JaegerRemoteSampler({
endpoint,
serviceName,
poolingInterval,
initialSampler: alwaysOnSampler,
});
await clock.tickAsync(poolingInterval * 2);
sinon.assert.callCount(getAndUpdateSamplerStub, 2);
sinon.assert.callCount(unhandledRejectionListener, 0);
});
});

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

0 comments on commit a3983fa

Please sign in to comment.