Documentation
    Preparing search index...

    Checks for the memory RSS size and report warning or error after a certain threshold is exceeded.

    const rssCheck = new MemoryRSSCheck()
    .as('RSS memory usage check')
    .warnWhenExceeds('300 mb')
    .failWhenExceeds('400 mb')
    .cacheFor('1 minute')

    const result = await rssCheck.run()
    console.log(result.status) // 'ok' | 'warning' | 'error'

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cacheDuration?: number

    The cache duration for the check result in seconds

    name: string = 'Memory RSS check'

    The name of the memory RSS check

    Methods

    • Define a custom unique name for the check

      Parameters

      • name: string

        The unique name for the health check

      Returns this

      const check = new MyCheck().as('Database connection check')
      
    • Specify the duration for which the check should be cached for

      Parameters

      • duration: string | number

        The cache duration as a string (e.g., '5s', '1m') or number in seconds

      Returns MemoryRSSCheck

      const check = new MyCheck().cacheFor('5 minutes')
      // or
      const check2 = new MyCheck().cacheFor(300) // 300 seconds
    • Define the RSS threshold after which a warning should be created.

      • The value should be either a number in bytes
      • Or it should be a value expression in string.
      .warnWhenExceeds('200 mb')
      

      Parameters

      • value: string | number

        The threshold value as bytes (number) or string expression

      Returns MemoryRSSCheck

    • Define the RSS threshold after which an error should be created.

      • The value should be either a number in bytes
      • Or it should be a value expression in string.
      .failWhenExceeds('500 mb')
      

      Parameters

      • value: string | number

        The threshold value as bytes (number) or string expression

      Returns MemoryRSSCheck

    • Define a custom callback to compute the RSS size. Defaults to using "process.memoryUsage()" method call

      Parameters

      • callback: () => MemoryUsage

        Function that returns memory usage information

      Returns this

      const rssCheck = new MemoryRSSCheck()
      .compute(() => {
      // Custom RSS computation logic
      const usage = process.memoryUsage()
      return { ...usage, rss: usage.rss * 0.9 } // Custom adjustment
      })