package.dist.src.config.middleware.impl.experimental-metrics-middleware.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
Client SDK for Momento services
The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExperimentalMetricsMiddleware = exports.ExperimentalMetricsMiddlewareRequestHandler = void 0;
const cache_data_client_1 = require("../../../internal/cache-data-client");
const FIELD_NAMES = [
'numActiveRequestsAtStart',
'numActiveRequestsAtFinish',
'requestType',
'status',
'startTime',
'requestBodyTime',
'endTime',
'duration',
'requestSize',
'responseSize',
'connectionID',
];
class ExperimentalMetricsMiddlewareRequestHandler {
constructor(parent, logger, context) {
this.parent = parent;
this.logger = logger;
this.connectionID = context[cache_data_client_1.CONNECTION_ID_KEY];
this.numActiveRequestsAtStart = parent.incrementActiveRequestCount();
this.startTime = new Date().getTime();
this.receivedResponseBody = false;
this.receivedResponseStatus = false;
}
onRequestBody(request) {
this.requestSize = request.messageLength();
this.requestType = request._grpcMessage.constructor.name;
this.requestBodyTime = new Date().getTime();
return Promise.resolve(request);
}
onRequestMetadata(metadata) {
return Promise.resolve(metadata);
}
onResponseBody(response) {
if (response !== null) {
this.responseSize = response.messageLength();
}
else {
this.responseSize = 0;
}
this.receivedResponseBody = true;
if (this.done())
this.recordMetrics();
return Promise.resolve(response);
}
onResponseMetadata(metadata) {
return Promise.resolve(metadata);
}
onResponseStatus(status) {
this.receivedResponseStatus = true;
this.responseStatusCode = status.code();
if (this.done())
this.recordMetrics();
return Promise.resolve(status);
}
done() {
return this.receivedResponseBody && this.receivedResponseStatus;
}
recordMetrics() {
const endTime = new Date().getTime();
const metrics = {
momento: {
numActiveRequestsAtStart: this.numActiveRequestsAtStart,
numActiveRequestsAtFinish: this.parent.activeRequestCount(),
requestType: this.requestType,
status: this.responseStatusCode,
startTime: this.startTime,
requestBodyTime: this.requestBodyTime,
endTime: endTime,
duration: endTime - this.startTime,
requestSize: this.requestSize,
responseSize: this.responseSize,
connectionID: this.connectionID,
},
};
this.emitMetrics(metrics).catch(e =>
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.logger.error(`An error occurred when trying to emit metrics: ${e}`));
this.parent.decrementActiveRequestCount();
}
}
exports.ExperimentalMetricsMiddlewareRequestHandler = ExperimentalMetricsMiddlewareRequestHandler;
/**
* This middleware enables per-request client-side metrics. This is an abstract
* class that does not route the metrics to a specific destination; concrete subclasses
* may store the metrics as they see fit.
*
* The metrics format is currently considered experimental; in a future release,
* once the format is considered stable, this class will be renamed to remove
* the Experimental prefix.
*
* WARNING: enabling this middleware may have minor performance implications,
* so enable with caution.
*
* See `advanced.ts` in the examples directory for an example of how to set up
* your {Configuration} to enable this middleware.
*/
class ExperimentalMetricsMiddleware {
constructor(loggerFactory, requestHandlerFactoryFn) {
this.numActiveRequests = 0;
this.logger = loggerFactory.getLogger(this);
this.requestHandlerFactoryFn = requestHandlerFactoryFn;
}
fieldNames() {
return FIELD_NAMES;
}
incrementActiveRequestCount() {
return ++this.numActiveRequests;
}
activeRequestCount() {
return this.numActiveRequests;
}
decrementActiveRequestCount() {
--this.numActiveRequests;
}
onNewRequest(context) {
return this.requestHandlerFactoryFn(this, this.logger, context);
}
}
exports.ExperimentalMetricsMiddleware = ExperimentalMetricsMiddleware;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZXJpbWVudGFsLW1ldHJpY3MtbWlkZGxld2FyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9jb25maWcvbWlkZGxld2FyZS9pbXBsL2V4cGVyaW1lbnRhbC1tZXRyaWNzLW1pZGRsZXdhcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBU0EsMkVBQXNFO0FBRXRFLE1BQU0sV0FBVyxHQUFrQjtJQUNqQywwQkFBMEI7SUFDMUIsMkJBQTJCO0lBQzNCLGFB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