Skip to content

Commit

Permalink
feat(meetings): incremental log uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-bazyl committed Oct 9, 2024
1 parent d78f855 commit 3c77ffa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@webex/internal-plugin-support/src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const Support = WebexPlugin.extend({
return this.webex.upload(options);
})
.then((body) => {
this.webex.logger.clearBuffers();

if (userId && !body.userId) {
body.userId = userId;
}
Expand Down
14 changes: 14 additions & 0 deletions packages/@webex/plugin-logger/src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ const Logger = WebexPlugin.extend({
return this.getCurrentLevel();
},

/**
* Clears the log buffers
*
* @instance
* @memberof Logger
* @public
* @returns {undefined}
*/
clearBuffers() {
this.clientBuffer = [];
this.sdkBuffer = [];
this.buffer = [];
},

/**
* Format logs (for upload)
*
Expand Down
1 change: 1 addition & 0 deletions packages/@webex/plugin-meetings/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ export default {
degradationPreferences: {
maxMacroblocksLimit: 8192,
},
logUploadInterval: 60 * 10, // in seconds
},
};
40 changes: 40 additions & 0 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import jwtDecode from 'jwt-decode';
import {StatelessWebexPlugin} from '@webex/webex-core';
// @ts-ignore - Types not available for @webex/common
import {Defer} from '@webex/common';
import {safeSetTimeout, safeSetInterval} from '@webex/common-timers';
import {
ClientEvent,
ClientEventLeaveReason,
Expand Down Expand Up @@ -700,6 +701,7 @@ export default class Meeting extends StatelessWebexPlugin {
private iceCandidateErrors: Map<string, number>;
private iceCandidatesCount: number;
private rtcMetrics?: RtcMetrics;
private uploadLogsIntervalId?: ReturnType<typeof setInterval>;

/**
* @param {Object} attrs
Expand Down Expand Up @@ -3964,6 +3966,43 @@ export default class Meeting extends StatelessWebexPlugin {
Trigger.trigger(this, options, EVENTS.REQUEST_UPLOAD_LOGS, this);
}

/**
* Starts a periodic upload of logs
*
* @returns {undefined}
*/
public startPeriodicLogUpload() {
if (!this.uploadLogsIntervalId) {
// start a periodic log upload after an initial delay of a few seconds to let things settle down first
safeSetTimeout(() => {
this.uploadLogs();

this.uploadLogsIntervalId = safeSetInterval(() => {
this.uploadLogs();

// just as an extra precaution, to avoid uploading logs forever in case something goes wrong
// and the page remains opened, we stop it if there is no media connection
if (!this.mediaProperties.webrtcMediaConnection) {
this.stopPeriodicLogUpload();
}
// @ts-ignore - config coming from registerPlugin
}, this.config.logUploadInterval * 1000);
}, 3000);
}
}

/**
* Stops the periodic upload of logs
*
* @returns {undefined}
*/
public stopPeriodicLogUpload() {
if (this.uploadLogsIntervalId) {
clearInterval(this.uploadLogsIntervalId);
this.uploadLogsIntervalId = undefined;
}
}

/**
* Removes remote audio, video and share streams from class instance's mediaProperties
* @returns {undefined}
Expand Down Expand Up @@ -7130,6 +7169,7 @@ export default class Meeting extends StatelessWebexPlugin {

// We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
this.remoteMediaManager?.logAllReceiveSlots();
this.startPeriodicLogUpload();
} catch (error) {
LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);

Expand Down
1 change: 1 addition & 0 deletions packages/@webex/plugin-meetings/src/meeting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const MeetingUtil = {

cleanUp: (meeting) => {
meeting.getWebexObject().internal.device.meetingEnded();
meeting.stopPeriodicLogUpload();

meeting.breakouts.cleanUp();
meeting.simultaneousInterpretation.cleanUp();
Expand Down

0 comments on commit 3c77ffa

Please sign in to comment.