import { Middleware, MiddlewareMessage, MiddlewareMetadata, MiddlewareRequestHandler, MiddlewareRequestHandlerContext, MiddlewareStatus } from '../middleware'; import { MomentoLogger, MomentoLoggerFactory } from '@gomomento/sdk-core'; export interface ExperimentalRequestMetrics { momento: { /** * number of requests active at the start of the request */ numActiveRequestsAtStart: number; /** * number of requests active at the finish of the request (including the request itself) */ numActiveRequestsAtFinish: number; /** * The generated grpc object type of the request */ requestType: string; /** * The grpc status code of the response */ status: number; /** * The time the request started (millis since epoch) */ startTime: number; /** * The time the body of the request was available to the grpc library (millis since epoch) */ requestBodyTime: number; /** * The time the request completed (millis since epoch) */ endTime: number; /** * The duration of the request (in millis) */ duration: number; /** * The size of the request body in bytes */ requestSize: number; /** * The size of the response body in bytes */ responseSize: number; /** * The ID of the specific connection that made the request */ connectionID: string; }; } export declare abstract class ExperimentalMetricsMiddlewareRequestHandler implements MiddlewareRequestHandler { protected readonly parent: ExperimentalMetricsMiddleware; protected readonly logger: MomentoLogger; private readonly connectionID; private readonly numActiveRequestsAtStart; private readonly startTime; private requestBodyTime; private requestType; private requestSize; private responseStatusCode; private responseSize; private receivedResponseBody; private receivedResponseStatus; constructor(parent: ExperimentalMetricsMiddleware, logger: MomentoLogger, context: MiddlewareRequestHandlerContext); abstract emitMetrics(metrics: ExperimentalRequestMetrics): Promise; onRequestBody(request: MiddlewareMessage): Promise; onRequestMetadata(metadata: MiddlewareMetadata): Promise; onResponseBody(response: MiddlewareMessage | null): Promise; onResponseMetadata(metadata: MiddlewareMetadata): Promise; onResponseStatus(status: MiddlewareStatus): Promise; private done; protected recordMetrics(): void; } /** * 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. */ export declare abstract class ExperimentalMetricsMiddleware implements Middleware { private numActiveRequests; protected readonly logger: MomentoLogger; private readonly requestHandlerFactoryFn; constructor(loggerFactory: MomentoLoggerFactory, requestHandlerFactoryFn: (parent: ExperimentalMetricsMiddleware, logger: MomentoLogger, context: MiddlewareRequestHandlerContext) => MiddlewareRequestHandler); fieldNames(): Array; incrementActiveRequestCount(): number; activeRequestCount(): number; decrementActiveRequestCount(): void; onNewRequest(context: MiddlewareRequestHandlerContext): MiddlewareRequestHandler; }