Observability components for Pip.Services in Python
Project description
Observability Components for Python
This module is a part of the Pip.Services polyglot microservices toolkit.
The Observability module contains observability component definitions that can be used to build applications and services.
The module contains the following packages:
- Count - performance counters
- Log - basic logging components that provide console and composite logging, as well as an interface for developing custom loggers
- Trace - tracing components
Use
Install the Python package as
pip install pip_services4_observability
Example how to use Logging and Performance counters. Here we are going to use CompositeLogger and CompositeCounters components. They will pass through calls to loggers and counters that are set in references.
from pip_services3_commons.config import ConfigParams, IConfigurable
from pip_services3_commons.refer import IReferences, IReferenceable
from pip_services3_components.count import CompositeCounters
from pip_services3_components.log import CompositeLogger
class MyComponent(IConfigurable, IReferenceable):
__logger = CompositeLogger()
__counters = CompositeCounters()
def configure(self, config):
self.__logger.configure(config)
def set_references(self, references):
self.__logger.set_references(references)
self.__counters.set_references(references)
def my_method(self, context, param1):
try:
self.__logger.trace(context, "Executed method mycomponent.mymethod")
self.__counters.increment("mycomponent.mymethod.exec_count", 1)
timing = self.__counters.begin_timing("mycomponent.mymethod.exec_time")
# ...
timing.end_timing()
except Exception as ex:
self.__logger.error(context, ex, "Failed to execute mycomponent.mymethod")
self.__counters.increment("mycomponent.mymethod.error_count", 1)
Develop
For development you shall install the following prerequisites:
- Python 3.7+
- Visual Studio Code or another IDE of your choice
- Docker
Install dependencies:
pip install -r requirements.txt
Run automated tests:
python test.py
Generate API documentation:
./docgen.ps1
Before committing changes run dockerized build and test as:
./build.ps1
./test.ps1
./clear.ps1
Contacts
The initial implementation is done by Sergey Seroukhov. Pip.Services team is looking for volunteers to take ownership over Python implementation in the project.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pip_services4_observability-0.0.3.tar.gz
.
File metadata
- Download URL: pip_services4_observability-0.0.3.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1373bffb534ec66c7866b150475ee37aca4b32e3ccf849557633d355be7f75f7 |
|
MD5 | 3317dc7d191931e16d8be2cc72299b2f |
|
BLAKE2b-256 | 94bbfd52163f96f14e3753bbc8b421fec7f7352ce72e535c9571ce4b08fab79a |