@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
142 lines (141 loc) • 3.95 kB
TypeScript
import { ChildProcess } from 'child_process';
export declare const API_REQUESTS_CHANNEL_NAME = "api-requests";
export declare const FUNCTION_REPORTS_CHANNEL_NAME = "function-reports";
export declare class MonitoringManager {
private queryWorker;
private fetchAndLockWorker?;
private runtimeWorker?;
private logger;
private iterations;
private intervals;
private apiRequestsChannelSubscription;
private functionReportsChannelSubscription;
static getNewFunctionReporter(name: string, parameters?: any, values?: any): FunctionReporter;
static amountOfIterations(): number;
static timeBetweenIterations(): number;
static timeBetweenStatsCollection(): number;
static timeBetweenReportPrint(): number;
static enableReportPrint(): boolean;
static disableAuth(): boolean;
static metricsEnabled(): boolean;
init(runtimeWorker: ChildProcess, queryWorker?: ChildProcess, fetchAndLockWorker?: ChildProcess): void;
printReport(): void;
private reportApiRequest;
private reportFunctionReport;
getReport(): FullReport;
dispose(): void;
private getFunctionsReport;
private getMemoryUsageReport;
private getCPUUsageReport;
private getApiRequestsReport;
private getSystemStatsReport;
private getSystemStats;
private rotateIteration;
private collectStats;
private getHumanReadableCpu;
private getHumanReadableMemory;
private getHumanReadableTime;
private getNewIteration;
private getLatestIteration;
private getMergedIterations;
static getNumberFromEnv(env: string): number;
static getBooleanFromEnv(env: string): boolean;
}
type SystemStatsReport = {
totalMemory: string;
freeMemory: string;
heapSizeLimit: string;
};
type CPUUsageReport = {
main: {
current: string;
average: string;
};
query: {
current: string;
average: string;
};
fetchAndLock: {
current: string;
average: string;
};
runtime: {
current: string;
average: string;
};
};
type MemoryUsageReport = {
main: {
current: string;
average: string;
};
query: {
current: string;
average: string;
};
fetchAndLock: {
current: string;
average: string;
};
runtime: {
current: string;
average: string;
};
};
type ApiRequestsReport = {
[route: string]: {
count: number;
averageDuration: number;
maxDuration: number;
minDuration: number;
averageRequestPayloadSize: string;
averageResponsePayloadSize: string;
maxRequestPayloadSize: string;
minRequestPayloadSize: string;
maxResponsePayloadSize: string;
minResponsePayloadSize: string;
};
};
export type FullReport = {
cpuUsage: CPUUsageReport;
memoryUsage: MemoryUsageReport;
systemStats: SystemStatsReport;
apiRequests: ApiRequestsReport;
functionsReport: FunctionsReport;
oldestIterationTimestamp: Date;
};
export type PartialFunctionReport = {
id: string;
name: string;
totalDuration: number;
startedAt: Date;
workerId: string;
currentTimestamp: Date;
finished: boolean;
values?: string;
parameters?: string;
callstack?: string;
};
export type FunctionAggregateReport = {
totalDuration: number;
averageDuration: number;
maxDuration: number;
minDuration: number;
count: number;
timestamps: Array<Date>;
values?: Array<string>;
parameters?: string;
callstack?: string;
};
export type FunctionsReport = {
[workerId: string]: {
[functionName: string]: Array<FunctionAggregateReport>;
};
};
export declare class FunctionReporter {
private partialFunctionReport;
constructor(partialFunctionReport: PartialFunctionReport);
updateAndSend(finished?: boolean): void;
finish(): void;
}
export {};