IStats is the interface used to implement statistics seralization The serialized object can then be sent to a server for analysis with Telemetry.

Example

// MyStats implementation
class MyStats extends IStats {
constructor(obj) {
this._obj = obj;
// Subscribe to onClose event to signal object release (will stop this stats report)
obj.onClose = () => this.onRelease();
}
async serialize() {
// serialize stats to a JSON object {recvBytes, sendBytes}
return {
recvBytes: this._obj.recvBytes,
sendBytes: this._obj.sendBytes
}
}
}

Hierarchy

Implemented by

Properties

Methods

Events

Properties

log: ILog

Start a log

Param

Returns

a Log object with the levels of log to call

Methods

  • Implements this function to define how to serialize data. The function must return the metrics object or reject the Promise if the serialization is not possible.

    Returns Promise<string | object | ArrayBuffer>

    an async string for a text/plain response, an object for a JSON response, or ArrayBuffer for a binary response

Events

Generated using TypeDoc