Skip to content

Commit

Permalink
Fix 'd' trace httpList metric reporting (#3986)
Browse files Browse the repository at this point in the history
- Ensure 'd' (Measurement period duration) trace httpList metric reflects that used by ABR
- Limit use of throughput metric to FetchLoader
- Remove throughput metric from trace object
- Simplify ThroughputHistory rules
  • Loading branch information
piersoh committed Jul 18, 2022
1 parent a3de367 commit a69379b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/streaming/models/MetricsModel.js
Expand Up @@ -116,13 +116,12 @@ function MetricsModel(config) {
}
}

function appendHttpTrace(httpRequest, s, d, b, t) {
function appendHttpTrace(httpRequest, s, d, b) {
let vo = new HTTPRequestTrace();

vo.s = s;
vo.d = d;
vo.b = b;
vo._t = t;

httpRequest.trace.push(vo);

Expand Down Expand Up @@ -188,7 +187,7 @@ function MetricsModel(config) {

if (traces) {
traces.forEach(trace => {
appendHttpTrace(vo, trace.s, trace.d, trace.b, trace.t);
appendHttpTrace(vo, trace.s, trace.d, trace.b);
});
} else {
// The interval and trace shall be absent for redirect and failure records.
Expand Down
10 changes: 8 additions & 2 deletions src/streaming/net/FetchLoader.js
Expand Up @@ -231,16 +231,22 @@ function FetchLoader(cfg) {
// are correctly generated
// Same structure as https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget/
let calculatedThroughput = null;
let calculatedTime = null;
if (calculationMode === Constants.ABR_FETCH_THROUGHPUT_CALCULATION_MOOF_PARSING) {
calculatedThroughput = calculateThroughputByChunkData(startTimeData, endTimeData);
if (calculatedThroughput) {
calculatedTime = bytesReceived * 8 / calculatedThroughput;
}
}
else if (calculationMode === Constants.ABR_FETCH_THROUGHPUT_CALCULATION_DOWNLOADED_DATA) {
calculatedTime = calculateDownloadedTime(downloadedData, bytesReceived);
}

httpRequest.progress({
loaded: bytesReceived,
total: isNaN(totalBytes) ? bytesReceived : totalBytes,
lengthComputable: true,
time: calculateDownloadedTime(downloadedData, bytesReceived),
throughput: calculatedThroughput,
time: calculatedTime,
stream: true
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/streaming/net/HTTPLoader.js
Expand Up @@ -208,8 +208,7 @@ function HTTPLoader(cfg) {
traces.push({
s: lastTraceTime,
d: event.time ? event.time : currentTime.getTime() - lastTraceTime.getTime(),
b: [event.loaded ? event.loaded - lastTraceReceivedCount : 0],
t: event.throughput
b: [event.loaded ? event.loaded - lastTraceReceivedCount : 0]
});

lastTraceTime = currentTime;
Expand Down
9 changes: 1 addition & 8 deletions src/streaming/rules/ThroughputHistory.js
Expand Up @@ -91,14 +91,7 @@ function ThroughputHistory(config) {
let throughputMeasureTime = 0, throughput = 0;

if (httpRequest._fileLoaderType && httpRequest._fileLoaderType === Constants.FILE_LOADER_TYPES.FETCH) {
const calculationMode = settings.get().streaming.abr.fetchThroughputCalculationMode;
if (calculationMode === Constants.ABR_FETCH_THROUGHPUT_CALCULATION_MOOF_PARSING) {
const sumOfThroughputValues = httpRequest.trace.reduce((a, b) => a + b._t, 0);
throughput = Math.round(sumOfThroughputValues / httpRequest.trace.length);
}
if (throughput === 0) {
throughputMeasureTime = httpRequest.trace.reduce((a, b) => a + b.d, 0);
}
throughputMeasureTime = httpRequest.trace.reduce((a, b) => a + b.d, 0);
} else {
throughputMeasureTime = useDeadTimeLatency ? downloadTimeInMilliseconds : latencyTimeInMilliseconds + downloadTimeInMilliseconds;
}
Expand Down
5 changes: 0 additions & 5 deletions src/streaming/vo/metrics/HTTPRequest.js
Expand Up @@ -159,11 +159,6 @@ class HTTPRequestTrace {
* @public
*/
this.b = [];
/**
* Measurement throughput in kbits/s
* @public
*/
this._t = null;
}
}

Expand Down

0 comments on commit a69379b

Please sign in to comment.