Add config option to turn on in-room event sending timing metrics

This is intended to be hooked up to an external system. 

Due to the extra events and metadata concerns, this is only available if turned on from the config.

See `sendTimePerformanceMetrics.ts` for event schemas.
This commit is contained in:
Travis Ralston 2021-09-08 11:26:54 -06:00
parent 7ecb3c8dc7
commit 21e33362e5
4 changed files with 73 additions and 0 deletions

View file

@ -39,6 +39,8 @@ import {
import { IUpload } from "./models/IUpload";
import { IAbortablePromise, IImageInfo } from "matrix-js-sdk/src/@types/partials";
import { BlurhashEncoder } from "./BlurhashEncoder";
import SettingsStore from "./settings/SettingsStore";
import { decorateStartSendingTime, sendRoundTripMetric } from "./sendTimePerformanceMetrics";
const MAX_WIDTH = 800;
const MAX_HEIGHT = 600;
@ -539,6 +541,10 @@ export default class ContentMessages {
msgtype: "", // set later
};
if (SettingsStore.getValue("Performance.addSendMessageTimingMetadata")) {
decorateStartSendingTime(content);
}
// if we have a mime type for the file, add it to the message metadata
if (file.type) {
content.info.mimetype = file.type;
@ -614,6 +620,11 @@ export default class ContentMessages {
}).then(function() {
if (upload.canceled) throw new UploadCanceledError();
const prom = matrixClient.sendMessage(roomId, content);
if (SettingsStore.getValue("Performance.addSendMessageTimingMetadata")) {
prom.then(resp => {
sendRoundTripMetric(matrixClient, roomId, resp.event_id);
});
}
CountlyAnalytics.instance.trackSendMessage(startTime, prom, roomId, false, false, content);
return prom;
}, function(err) {