Skip to content

Commit

Permalink
feat(ca-metrics): fix negative timestamps (#3313)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Miller <[email protected]>
  • Loading branch information
stevem63 and Steven Miller authored Jan 18, 2024
1 parent fad9000 commit 09a0f13
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
}
// for some events we're only interested in the first timestamp not last
// as these events can happen multiple times
if (key === 'client.media.rx.start' || key === 'client.media.tx.start') {
if (
key === 'client.media.rx.start' ||
key === 'client.media.tx.start' ||
key === 'internal.client.meetinginfo.request' ||
key === 'internal.client.meetinginfo.response'
) {
this.saveFirstTimestampOnly(key, value);
} else {
this.latencyTimestamps.set(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,35 @@ describe('internal-plugin-metrics', () => {
assert.deepEqual(cdl.getMeetingInfoReqResp(), 10);
});

it('calculates getMeetingInfoReqResp correctly when duplicate requests/responses are sent', () => {
cdl.saveTimestamp({key: 'internal.client.meetinginfo.request', value: 8});
cdl.saveTimestamp({key: 'internal.client.meetinginfo.response', value: 18});
cdl.saveTimestamp({key: 'internal.client.meetinginfo.request', value: 47});
cdl.saveTimestamp({key: 'internal.client.meetinginfo.response', value: 48});
assert.deepEqual(cdl.getMeetingInfoReqResp(), 10);
});

describe('saveTimestamp', () => {

afterEach(() => {
sinon.restore();
});

it('calls saveFirstTimestamp for meeting info request', () => {
const saveFirstTimestamp = sinon.stub(cdl, 'saveFirstTimestampOnly');
cdl.saveTimestamp({key: 'internal.client.meetinginfo.request', value: 10});
cdl.saveTimestamp({key: 'client.alert.displayed', value: 15});
assert.deepEqual(saveFirstTimestamp.callCount, 1);
});

it('calls saveFirstTimestamp for meeting info response', () => {
const saveFirstTimestamp = sinon.stub(cdl, 'saveFirstTimestampOnly');
cdl.saveTimestamp({key: 'client.alert.displayed', value: 15});
cdl.saveTimestamp({key: 'internal.client.meetinginfo.response', value: 20});
assert.deepEqual(saveFirstTimestamp.callCount, 1);
});
});

it('calculates getShowInterstitialTime correctly', () => {
cdl.saveTimestamp({key: 'client.interstitial-window.start-launch', value: 10});
cdl.saveTimestamp({key: 'internal.client.interstitial-window.click.joinbutton', value: 20});
Expand Down

0 comments on commit 09a0f13

Please sign in to comment.