ContextInfo class

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

Constructors

ContextInfo([String? name, String? description])
Creates a new instance of this context info.

Properties

contextId String
Gets the unique context id. Usually it is the current host name.
getter/setter pair
description String?
Gets the human-readable description of the context.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
name String
Gets the context name.
getter/setter pair
properties ↔ dynamic
Gets context additional parameters.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startTime DateTime
Gets the context start time.
getter/setter pair
uptime int
Calculates the context uptime as from the start time.
no setter

Methods

configure(ConfigParams config) → void
Configures component by passing configuration parameters.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromConfig(ConfigParams config) ContextInfo
Creates a new ContextInfo and sets its configuration parameters.