All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.src.config.middleware.experimental-metrics-logging-middleware.js Maven / Gradle / Ivy

The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExperimentalMetricsLoggingMiddleware = void 0;
const experimental_metrics_middleware_1 = require("./impl/experimental-metrics-middleware");
class ExperimentalMetricsLoggingMiddlewareRequestHandler extends experimental_metrics_middleware_1.ExperimentalMetricsMiddlewareRequestHandler {
    constructor(parent, logger, context) {
        super(parent, logger, context);
    }
    emitMetrics(metrics) {
        this.logger.info(JSON.stringify(metrics));
        return Promise.resolve();
    }
}
/**
 * This middleware enables per-request client-side metrics.  Metrics for each
 * request will be written to logs; the log data can be analyzed or shared
 * with Momento to diagnose performance issues.
 *
 * 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.
 *
 * It also enables regular logging of congestion in the node event loop. Once
 * per second it will output the event loop utilization ratio, as well as stats
 * about the event loop delay, measured in 20ms increments.
 *
 * WARNING: enabling this middleware may have minor performance implications,
 * so enable with caution.
 *
 * WARNING: depending on your request volume, this middleware will produce a high
 * volume of log output. If you are writing logs directly to local disk, be aware
 * of disk usage and make sure you have log rotation / compression enabled via a
 * tool such as `logrotate`.
 *
 * See `advanced.ts` in the examples directory for an example of how to set up
 * your {Configuration} to enable this middleware.
 */
class ExperimentalMetricsLoggingMiddleware extends experimental_metrics_middleware_1.ExperimentalMetricsMiddleware {
    constructor(loggerFactory) {
        super(loggerFactory, (p, l, c) => new ExperimentalMetricsLoggingMiddlewareRequestHandler(p, l, c));
    }
}
exports.ExperimentalMetricsLoggingMiddleware = ExperimentalMetricsLoggingMiddleware;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZXJpbWVudGFsLW1ldHJpY3MtbG9nZ2luZy1taWRkbGV3YXJlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4v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