Implements: IReconfigurable
Description
The ContextInfo class allows you to create context information components that provide detailed information about execution contexts.
Important points
- Most often ContextInfo is used by logging and performance counters to identify the 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
 - …
 
Constructors
Creates a new instance of this context info.
publicconstructor(name?: string, description?: string)
- name: string - (optional) a context name.
 - description: string - (optional) a human-readable description of the context.
 
Properties
contextId
Gets the unique context id. Usually it is the current host name.
publiccontextId(): string
- returns: string - the unique context id.
 
Gets the unique context id. Usually it is the current host name.
publiccontextId(context_id: string)
- contextId: string - the unique context id.
 
description
Gets the human-readable description of the context.
publicdescription(): string
- returns: string - the human-readable description of the context.
 
Sets the human-readable description of the context.
publicdescription(description: string)
- description: string - a new human readable description of the context.
 
name
Gets the context name.
publicname(): string
- returns: string - the context name
 
Sets the context name.
publicname(name: string)
- name: string - a new name for the context.
 
properties
Gets context additional parameters.
publicproperties(): any
- returns: any - a JSON object with additional context parameters.
 
Sets context additional parameters.
publicproperties(properties: any)
- properties: any - a JSON object with context additional parameters
 
startTime
Gets the context start time.
publicstartTime(): Date
- returns: any - a JSON object with additional context parameters.
 
Sets the context start time.
publicstartTime(start_time: Date)
- start_time: Date - a new context start time.
 
Instance methods
configure
Configures component by passing configuration parameters.
publicconfigure(config: ConfigParams): void
- config: ConfigParams - configuration parameters to be set.
 
Static methods
fromConfig
Creates a new ContextInfo and sets its configuration parameters.
public staticfromConfig(config: ConfigParams): ContextInfo
- config: ConfigParams - configuration parameters for the new ContextInfo.
 - returns: ContextInfo - a newly created ContextInfo
 
Examples
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