traceperf
    Preparing search index...

    Class OptimizedPerformanceMonitor

    Main performance monitoring interface

    Hierarchy (View Summary)

    Index
    • Create a trackable version of a function

      Type Parameters

      • T extends (...args: any[]) => any

      Parameters

      • fn: T

        The function to track

      • options: TrackOptions = {}

        Tracking options

      Returns (...args: Parameters<T>) => ReturnType<T>

      Tracked version of the function

    • Call listener for every finished call (nested ones included) that took at least threshold ms. Pass a number, or per-label thresholds with an optional '*' default:

      tp.onSlow(200, (call, root) => logger.warn(${call.label} took ${call.duration}ms in ${root.label})); tp.onSlow({ 'db.query': 50, 'GET /search': 500, '*': 1000 }, alert);

      Works in every tracking mode and when silent. Returns an unsubscribe function.

      Parameters

      Returns () => void

    • Start a manually-ended execution (a span), e.g. for a request:

      const span = tp.start('GET /users'); span.run(() => next()); // tracked calls inside become children res.on('finish', () => span.end());

      Parameters

      Returns Span

    • Track every method of an object or class instance, including methods inherited from its prototype, without copying it. Returns a proxy: state changes go to the original object, and methods run with the original object as this (so private #fields keep working).

      Type Parameters

      • T extends object

      Parameters

      Returns T