Use new hocuspocus hooks for collaboration metrics
This commit is contained in:
@ -1,37 +1,58 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import Metrics from "../logging/metrics";
|
import Metrics from "../logging/metrics";
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
export default class Tracing {
|
export default class Tracing {
|
||||||
async onCreateDocument({ documentName }: { documentName: string }) {
|
async onCreateDocument({
|
||||||
|
documentName,
|
||||||
|
instance,
|
||||||
|
}: {
|
||||||
|
documentName: string,
|
||||||
|
instance: any,
|
||||||
|
}) {
|
||||||
Metrics.increment("collaboration.create_document", { documentName });
|
Metrics.increment("collaboration.create_document", { documentName });
|
||||||
|
|
||||||
// TODO: Waiting for `instance` available in payload
|
Metrics.gaugePerInstance(
|
||||||
// Metrics.gaugePerInstance(
|
"collaboration.documents_count",
|
||||||
// "collaboration.documents_count",
|
instance.getDocumentsCount()
|
||||||
// instance.documents.size()
|
);
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAuthenticationFailed({ documentName }: { documentName: string }) {
|
async onAuthenticationFailed({ documentName }: { documentName: string }) {
|
||||||
Metrics.increment("collaboration.authentication_failed", { documentName });
|
Metrics.increment("collaboration.authentication_failed", { documentName });
|
||||||
}
|
}
|
||||||
|
|
||||||
async onConnect({ documentName }: { documentName: string }) {
|
async onConnect({
|
||||||
|
documentName,
|
||||||
|
instance,
|
||||||
|
}: {
|
||||||
|
documentName: string,
|
||||||
|
instance: any,
|
||||||
|
}) {
|
||||||
Metrics.increment("collaboration.connect", { documentName });
|
Metrics.increment("collaboration.connect", { documentName });
|
||||||
Metrics.gaugePerInstance("collaboration.connections_count", ++count);
|
Metrics.gaugePerInstance(
|
||||||
|
"collaboration.connections_count",
|
||||||
|
instance.getConnectionsCount()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDisconnect({ documentName }: { documentName: string }) {
|
async onDisconnect({
|
||||||
|
documentName,
|
||||||
|
instance,
|
||||||
|
}: {
|
||||||
|
documentName: string,
|
||||||
|
instance: any,
|
||||||
|
}) {
|
||||||
Metrics.increment("collaboration.disconnect", { documentName });
|
Metrics.increment("collaboration.disconnect", { documentName });
|
||||||
Metrics.gaugePerInstance("collaboration.connections_count", --count);
|
Metrics.gaugePerInstance(
|
||||||
|
"collaboration.connections_count",
|
||||||
|
instance.getConnectionsCount()
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: Waiting for `instance` available in payload
|
// TODO: Waiting for `instance` available in payload
|
||||||
// Metrics.gaugePerInstance(
|
Metrics.gaugePerInstance(
|
||||||
// "collaboration.documents_count",
|
"collaboration.documents_count",
|
||||||
// instance.documents.size()
|
instance.getDocumentsCount()
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onChange({ documentName }: { documentName: string }) {
|
async onChange({ documentName }: { documentName: string }) {
|
||||||
|
Reference in New Issue
Block a user