Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContextInfo

Context information component that provides detail information about execution context: container or/and process.

Most often ContextInfo is used by logging and performance counters to identify source of the collected logs and metrics.

Configuration parameters

  • name: the context (container or process) name
  • description: human-readable description of the context
  • properties: entire section of additional descriptive properties
  • ...

Example

let contextInfo = new ContextInfo();
contextInfo.configure(ConfigParams.fromTuples(
    "name", "MyMicroservice",
    "description", "My first microservice"
));

context.name;            // Result: "MyMicroservice"
context.contextId;        // Possible result: "mylaptop"
context.startTime;        // Possible result: 2018-01-01:22:12:23.45Z
context.uptime;            // Possible result: 3454345

Hierarchy

  • ContextInfo

Implements

  • any

Index

Constructors

constructor

  • new ContextInfo(name?: string, description?: string): ContextInfo
  • Creates a new instance of this context info.

    Parameters

    • Optional name: string

      (optional) a context name.

    • Optional description: string

      (optional) a human-readable description of the context.

    Returns ContextInfo

Accessors

contextId

  • get contextId(): string
  • set contextId(value: string): void
  • Gets the unique context id. Usually it is the current host name.

    Returns string

    the unique context id.

  • Sets the unique context id.

    Parameters

    • value: string

      a new unique context id.

    Returns void

    the unique context id.

description

  • get description(): string
  • set description(value: string): void
  • Gets the human-readable description of the context.

    Returns string

    the human-readable description of the context.

  • Sets the human-readable description of the context.

    Parameters

    • value: string

      a new human readable description of the context.

    Returns void

    the human-readable description of the context.

name

  • get name(): string
  • set name(value: string): void
  • Gets the context name.

    Returns string

    the context name

  • Sets the context name.

    Parameters

    • value: string

      a new name for the context.

    Returns void

    the context name

properties

  • get properties(): any
  • set properties(properties: any): void
  • Gets context additional parameters.

    Returns any

    a JSON object with additional context parameters.

  • Sets context additional parameters.

    Parameters

    • properties: any

      a JSON object with context additional parameters

    Returns void

    a JSON object with additional context parameters.

startTime

  • get startTime(): Date
  • set startTime(value: Date): void
  • Gets the context start time.

    Returns Date

    the context start time.

  • Sets the context start time.

    Parameters

    • value: Date

      a new context start time.

    Returns void

    the context start time.

uptime

  • get uptime(): number
  • Calculates the context uptime as from the start time.

    Returns number

    number of milliseconds from the context start time.

Methods

configure

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

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

Static fromConfig

  • Creates a new ContextInfo and sets its configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters for the new ContextInfo.

    Returns ContextInfo

    a newly created ContextInfo

Generated using TypeDoc