Skip to main content

Observability components for Pip.Services in Python

Project description

Pip.Services Logo
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

Quick links:

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

pip_services4_observability-0.0.4.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pip_services4_observability-0.0.4-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file pip_services4_observability-0.0.4.tar.gz.

File metadata

File hashes

Hashes for pip_services4_observability-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6d728e7d0427ad657cd4d77c67c134c042ab9da439cdd44457c63cd3dc82d5dd
MD5 418deb9a87009f3d30cb44717db3725d
BLAKE2b-256 f509a9fb92bf324e9baf59d1af5b604ad3c222616735111cafab8c154a64fa19

See more details on using hashes here.

File details

Details for the file pip_services4_observability-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pip_services4_observability-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4022083f4145a4f84932a11724207007c243e0cf65e38c605e78066c3852894c
MD5 a53cecec29089185e5705c4ea39e4c25
BLAKE2b-256 cd6141e55e8c3343d5ab283f4a3ebdf53da03e5e69d1ce779d3c8b5c0e54855a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page