@unito/integration-sdk
Version:
Integration SDK
27 lines (26 loc) • 974 B
TypeScript
/**
* Accumulates per-request metrics for Provider API calls.
*
* Created once per incoming request (in the start middleware), threaded through Context and RequestOptions,
* incremented by Provider on each API call, and logged by the finish middleware.
*/
export declare class RequestMetrics {
private _apiCallCount;
private _totalApiDurationNs;
private _totalThrottleDelayNs;
private _requestStartTime;
private constructor();
static startRequest(): RequestMetrics;
endRequest(): {
durationNs: bigint;
apiCallCount: number;
totalApiDurationNs: number;
totalThrottleDelayNs: number;
};
/**
* Record a completed API call.
* Increments the call counter and accumulates the call's network duration and pre-flight
* throttle delay (time spent waiting in the rate limiter before the request was dispatched).
*/
recordExternalApiCall(duration: number, throttleDelay: number): void;
}