Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CachedTracer

Abstract tracer that caches recorded traces in memory and periodically dumps them. Child classes implement saving cached traces to their specified destinations.

Configuration parameters

  • source: source (context) name
  • options:
    • interval: interval in milliseconds to save log messages (default: 10 seconds)
    • max_cache_size: maximum number of messages stored in this cache (default: 100)

References

  • *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source
see

ITracer

see

OperationTrace

Hierarchy

  • CachedTracer

Implements

Index

Constructors

constructor

  • Creates a new instance of the logger.

    Returns CachedTracer

Properties

Protected _cache

_cache: OperationTrace[] = []

Protected _interval

_interval: number = 10000

Protected _lastDumpTime

_lastDumpTime: number = new Date().getTime()

Protected _maxCacheSize

_maxCacheSize: number = 100

Protected _source

_source: string = null

Protected _updated

_updated: boolean = false

Methods

beginTrace

  • beginTrace(correlationId: string, component: string, operation: string): TraceTiming
  • Begings recording an operation trace

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • component: string

      a name of called component

    • operation: string

      a name of the executed operation.

    Returns TraceTiming

    a trace timing object.

clear

  • clear(): void
  • Clears (removes) all cached log messages.

    Returns void

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

dump

  • dump(): void
  • Dumps (writes) the currently cached log messages.

    see

    write

    Returns void

failure

  • failure(correlationId: string, component: string, operation: string, error: Error, duration: number): void
  • Records an operation failure with its name, duration and error

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • component: string

      a name of called component

    • operation: string

      a name of the executed operation.

    • error: Error

      an error object associated with this trace.

    • duration: number

      execution duration in milliseconds.

    Returns void

Protected Abstract save

  • Saves log messages from the cache.

    Parameters

    • messages: OperationTrace[]

      a list with log messages

    • callback: function

      callback function that receives error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

setReferences

  • setReferences(references: IReferences): void
  • Sets references to dependent components.

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    Returns void

trace

  • trace(correlationId: string, component: string, operation: string, duration: number): void
  • Records an operation trace with its name and duration

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • component: string

      a name of called component

    • operation: string

      a name of the executed operation.

    • duration: number

      execution duration in milliseconds.

    Returns void

Protected update

  • update(): void
  • Makes trace cache as updated and dumps it when timeout expires.

    see

    dump

    Returns void

Protected write

  • write(correlationId: string, component: string, operation: string, error: Error, duration: number): void
  • Writes a log message to the logger destination.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • component: string

      a name of called component

    • operation: string

      a name of the executed operation.

    • error: Error

      an error object associated with this trace.

    • duration: number

      execution duration in milliseconds.

    Returns void

Generated using TypeDoc