pip_services3_components.info package
Submodules
Module contents
pip_services3_components.info.__init__
Contains a simple object that defines the context of execution. For various logging functions we need to know what source we are logging from – what is the processes name, what the process is/does.
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_components.info.
ContextInfo
(name: str = None, description: str = None) Bases:
pip_services3_commons.config.IReconfigurable.IReconfigurable
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:
contextInfo = ContextInfo() contextInfo.configure(ConfigParams.from_tuples( "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
-
configure
(config: pip_services3_commons.config.ConfigParams.ConfigParams) Configures component by passing configuration parameters.
- Parameters
config – configuration parameters to be set.
-
property
context_id
Gets the unique context id. Usually it is the current host name.
- Returns
the unique context id.
-
property
description
Gets the human-readable description of the context.
- Returns
the human-readable description of the context.
-
static
from_config
(config: pip_services3_commons.config.ConfigParams.ConfigParams) → <module ‘pip_services3_components.info.ContextInfo’ from ‘/pip_services3_components/info/ContextInfo.py’> Creates a new ContextInfo and sets its configuration parameters.
- Parameters
config – configuration parameters for the new ContextInfo.
- Returns
a newly created ContextInfo
-
property
name
Gets the context name.
- Returns
the context name
-
property
properties
Gets context additional parameters.
- Returns
a JSON object with additional context parameters.
-
property
start_time
Gets the context start time.
- Returns
the context start time.
-
property
uptime
Calculates the context uptime as from the start time.
- Returns
number of milliseconds from the context start time.
-
class
pip_services3_components.info.
DefaultInfoFactory
Bases:
pip_services3_components.build.Factory.Factory
Creates information components by their descriptors.
See
IFactory
,ContextInfo
-
ContainerInfoDescriptor
= <pip_services3_commons.refer.Descriptor.Descriptor object>
-
ContextInfoDescriptor
= <pip_services3_commons.refer.Descriptor.Descriptor object>
-