Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PerformanceApiManager

The manager responsible for the PerformanceApi created by the current package instance.

NOTE:

This class is not intended to be instantiated directly. It should be accessed through the PerfTiming variable instantiated by this package. Failure to do so will result in lost metrics in the final file output.

Hierarchy

  • PerformanceApiManager

Implements

Index

Constructors

constructor

  • The constructor will instantiate this manager and determine if performance monitoring is enabled.

    If the monitoring is enabled, it will also calculate the name of the global symbol. Also, if the global symbol has not been instantiated, this manager will be the default one and will be the one responsible for saving all data to the files.

    Returns PerformanceApiManager

Properties

Private _api

A reference to the performance api that is managed by this specific manager.

Private _instanceSymbol

_instanceSymbol: symbol

A symbol to uniquely identify the _api in the NodeJS.Global symbol.

isEnabled

isEnabled: boolean

A boolean set by the constructor indicating if performance is enabled.

packageUUID

packageUUID: string

The unique identifier of this current package instance. This will be the name@version of the closest package.json relative to the location of the first file that imported this package.

Static ENV_ENABLED

ENV_ENABLED: string = `${ENV_PREFIX}_ENABLED`

The environment variable that will be checked to determine if performance is enabled.

Static ENV_ENABLED_KEY

ENV_ENABLED_KEY: "TRUE" = "TRUE"

The value that the environment variable must be in order for performance gathering to be enabled.

Accessors

api

  • Gets the _api.

    NOTE:

    It is recommended that calls to the getApi method are contained within an if check to see if performance is enabled. This method will provide the least overhead for when performance is disabled but will add a some overhead when performance is enabled.

    NOTE:

    If performance is not enabled, this method will still return a PerformanceApi object and all methods can still be called the same way with performance enabled or disabled. With this in mind, it is not required that calls to this method are wrapped in a check to see if this is enabled, but it is still recommended.

    Returns PerformanceApi

    The performance api that is managed by this class.

Methods

Private _savePerformanceResults

  • _savePerformanceResults(): Promise<void>
  • Responsible for gathering and saving all metrics present within the environment.

    This method is only called by process.on('exit') defined in the constructor of the main manager. The nodeTiming and systemInformation portions of the IPerformanceMetrics object are gathered from the _api of this manager.

    Metrics are gathered by examining each API present in the {@link NodeJS.global} object. This design comes from the fact that there could be multiple instances of the PerfTiming package due to how npm dependencies work. So the main manager can find out about all possible metrics and output them in a single file as opposed to each manager creating it's own file. It is because of this fact that the methods in IPerformanceApi must not change too often for compatibility reasons.

    Returns Promise<void>

    a promise of completion.

Generated using TypeDoc