Skip to content

Commit

Permalink
feat: add tenant to track and pc (#117)
Browse files Browse the repository at this point in the history
* add tenant to track and pc

* minor fix

* small fix

* fix null ids

* fix 0 date format
  • Loading branch information
andrei-gavrilescu authored Sep 28, 2023
1 parent 9dba6b5 commit 037a872
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 42 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rtcstats-server",
"version": "2.22.1",
"version": "2.23.4",
"description": "The rtcstats-server represents the server side component of the rtcstats ecosystem, the client side being https://github.com/jitsi/rtcstats which collects and sends WebRTC related statistics.",
"main": "websocket.js",
"private": true,
Expand Down
108 changes: 69 additions & 39 deletions src/database/FeaturesPublisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,31 @@ class FeaturesPublisher {
* Extracts common dump fields from the given dump info object.
*
* @param {Object} dumpInfo - The dump info object to extract fields from.
* @param {Object} features - All the current session features.
* @returns {Object} An object containing the extracted fields under a common name.
*/
_extractCommonDumpFields(dumpInfo) {
_extractCommonDumpFields(dumpInfo, features) {
const {
clientId: statsSessionId,
sessionId: meetingUniqueId
sessionId: meetingUniqueId,
conferenceUrl: meetingUrl,
tenant,
jaasClientId
} = dumpInfo;

let {
conferenceStartTime
} = features;

conferenceStartTime = conferenceStartTime ? getSQLTimestamp(conferenceStartTime) : null;

return {
conferenceStartTime,
statsSessionId,
meetingUniqueId
meetingUniqueId,
meetingUrl,
tenant,
jaasClientId
};
}

Expand All @@ -49,7 +63,16 @@ class FeaturesPublisher {
* @param {Object} track - extracted track features.
* @param {Object} param1 - additional track related metadata.
*/
_publishTrackFeatures(track, { direction, statsSessionId, meetingUniqueId, isP2P, pcId, createDate }) {
_publishTrackFeatures(track, dumpInfo, features, { direction, isP2P, pcId, createDate }) {
const {
meetingUniqueId,
statsSessionId,
conferenceStartTime,
jaasClientId,
meetingUrl,
tenant
} = this._extractCommonDumpFields(dumpInfo, features);

const {
mediaType,
ssrc,
Expand Down Expand Up @@ -78,7 +101,11 @@ class FeaturesPublisher {
packetsLost,
packetsLostPct,
packetsLostVariance,
concealedPercentage
concealedPercentage,
conferenceStartTime,
jaasClientId,
meetingUrl,
tenant
};

if (startTime) {
Expand All @@ -95,17 +122,13 @@ class FeaturesPublisher {
/**
* Publish all peer connection track features.
* @param {Object} dumpInfo - Session metadata.
* @param {Object} features - All the current session features.
* @param {Object} pcRecord - Features associated with this specific peer connection.
* @param {Number} pcId - Unique pc entry identifier.
* @param {String} statsSessionId - rtcstats-server session id
* @param {String} createDate - SQL formatted timestamp string.
*/
_publishAllTrackFeatures(dumpInfo, pcRecord, pcId, createDate) {
const {
statsSessionId,
meetingUniqueId
} = this._extractCommonDumpFields(dumpInfo);

_publishAllTrackFeatures(dumpInfo, features, pcRecord, { id: pcId, createDate }) {
const {
isP2P,
tracks: {
Expand All @@ -114,23 +137,20 @@ class FeaturesPublisher {
}
} = pcRecord;

receiverTracks.forEach(rtrack => {
this._publishTrackFeatures(rtrack, { direction: 'received',
statsSessionId,
meetingUniqueId,
isP2P,
pcId,
createDate });
});
const publishTrack = (track, direction) => {
this._publishTrackFeatures(
track,
dumpInfo,
features, {
direction,
isP2P,
pcId,
createDate
});
};

senderTracks.forEach(strack => {
this._publishTrackFeatures(strack, { direction: 'send',
statsSessionId,
meetingUniqueId,
isP2P,
pcId,
createDate });
});
receiverTracks.forEach(track => publishTrack(track, 'received'));
senderTracks.forEach(track => publishTrack(track, 'send'));
}

/**
Expand All @@ -142,9 +162,13 @@ class FeaturesPublisher {
*/
_publishPCFeatures(dumpInfo, features, createDate) {
const {
meetingUniqueId,
statsSessionId,
meetingUniqueId
} = this._extractCommonDumpFields(dumpInfo);
conferenceStartTime,
jaasClientId,
meetingUrl,
tenant
} = this._extractCommonDumpFields(dumpInfo, features);

const {
aggregates: pcRecords = { }
Expand Down Expand Up @@ -212,11 +236,18 @@ class FeaturesPublisher {
meanUpperBoundFrameHeight: upperBoundAggregates.meanFrameHeight,
meanUpperBoundFramesPerSecond: upperBoundAggregates.meanFramesPerSecond,
meanLowerBoundFrameHeight: lowerBoundAggregates.meanFrameHeight,
meanLowerBoundFramesPerSecond: lowerBoundAggregates.meanFramesPerSecond
meanLowerBoundFramesPerSecond: lowerBoundAggregates.meanFramesPerSecond,
conferenceStartTime,
tenant,
jaasClientId,
meetingUrl
};

this._dbConnector.putPCFeaturesRecord(pcFeaturesRecord);
this._publishAllTrackFeatures(dumpInfo, pcRecords[pc], id, createDate);
this._publishAllTrackFeatures(dumpInfo, features, pcRecords[pc], {
id,
createDate
});
});
}

Expand Down Expand Up @@ -273,20 +304,21 @@ class FeaturesPublisher {
*/
_publishMeetingFeatures(dumpInfo, features, createDate) {
const {
conferenceStartTime,
jaasClientId,
meetingUniqueId,
meetingUrl,
statsSessionId,
meetingUniqueId
} = this._extractCommonDumpFields(dumpInfo);
tenant
} = this._extractCommonDumpFields(dumpInfo, features);

const {
userId: displayName,
conferenceId: meetingName,
conferenceUrl: meetingUrl,
endpointId,
isBreakoutRoom,
breakoutRoomId,
parentStatsSessionId,
tenant,
jaasClientId
parentStatsSessionId
} = dumpInfo;

const {
Expand All @@ -307,7 +339,6 @@ class FeaturesPublisher {
sessionDurationMs,
conferenceDurationMs
} = {},
conferenceStartTime: conferenceStartTimestamp,
sessionStartTime: sessionStartTimestamp,
sessionEndTime: sessionEndTimestamp,
dominantSpeakerChanges,
Expand All @@ -323,7 +354,6 @@ class FeaturesPublisher {
} = {}
} = features;

const conferenceStartTime = conferenceStartTimestamp ? getSQLTimestamp(conferenceStartTimestamp) : null;
const sessionStartTime = sessionStartTimestamp ? getSQLTimestamp(sessionStartTimestamp) : null;
const sessionEndTime = sessionEndTimestamp ? getSQLTimestamp(sessionEndTimestamp) : null;

Expand Down
6 changes: 6 additions & 0 deletions src/queries/redshift-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ CREATE TABLE IF NOT EXISTS rtcstats_pc_metrics (
meanUpperBoundFramesPerSecond REAL,
meanLowerBoundFrameHeight REAL,
meanLowerBoundFramesPerSecond REAL,
conferenceStartTime TIMESTAMP,
tenant: VARCHAR ( 512 ),
jaasClientId: VARCHAR ( 512 ),
PRIMARY KEY(id),
FOREIGN KEY (statssessionid) REFERENCES rtcstats(statssessionid)
)
Expand All @@ -99,6 +102,9 @@ CREATE TABLE IF NOT EXISTS rtcstats_track_metrics (
packetsLostPct REAL,
packetsLostVariance REAL,
concealedPercentage REAL,
conferenceStartTime TIMESTAMP,
tenant: VARCHAR ( 512 ),
jaasClientId: VARCHAR ( 512 ),
PRIMARY KEY(id),
FOREIGN KEY (pcId) REFERENCES rtcstats_pc_metrics(id)
)
Expand Down

0 comments on commit 037a872

Please sign in to comment.