Skip to main content

Standardized logging for metrics capture for applications with requirements.

Project description

STScI Metrics Logger

CI Powered by STScI Badge codecov

The metrics logger is a simple decorator intended to provide standardized logging for annotated pytest methods with tags to identify associated build requirements. As this is a generic utility, any method can be decorated and any type of tagging can be provided.

Log messages will follow a format that will provide:

  • METRIC - A static tag that will mark the beginning of the message.
  • Tags - A comma delimited list of the provided tags to the decorator.
  • Method - The decorated method name.
  • Result - FAIL if the method raises an exception and PASS otherwise.

The above will be delimited with a spaced hyphen: -

Note
Hyphens in the provided tags are supported.

Installation

The metrics_logger utility is not currently available in PyPi. To include it in a Conda environment, you can refer to it directly in your conda environment file in the pip section as follows:

dependencies:
  - pip
  - pip:
    metrics_logger https://github.com/spacetelescope/romancal.git

Development

metrics_logger development can be done with Conda.

Create and activate the environment

$ conda env create --file conda-env.yml
$ conda activate metrics-logger

Update the requirements

$ conda activate metrics-logger
$ conda env update --file conda-env.yml

Usage

Import the metrics_logger utility and insert it above the method to be annotated providing a list of tags as arguments. Each time the method is invoked, it will result in a log line being emitted to a logger named "metrics_logger".

Example:

from metrics_logger.decorators import metrics_logger

@metrics_logger('DMS86', 'DMS-129')
def test_some_functional_thing():
    assert True

Will result in the following log line (depending on log format):

2023-06-14 16:09:28,947 - stpipe - INFO - DMS86, DMS129 - test_some_functional_thing - PASS

Similarly:

@metrics_logger('DMS86', 'DMS-129')
def test_some_functional_thing():
    raise Exception("Oops!")

Will result in:

2023-06-14 16:10:09,221 - stpipe - INFO - DMS86, DMS129 - test_some_functional_thing - FAIL

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

metrics_logger-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

metrics_logger-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file metrics_logger-0.1.0.tar.gz.

File metadata

  • Download URL: metrics_logger-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for metrics_logger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02729240858639ccee404eb707782979d6b2b961bd0885be8411f5b31e0031bb
MD5 3000160b9503d08ab385fe2131b5163f
BLAKE2b-256 37578178414e1fdfd68c0c41ed3de1b8b33345f951c4553c3505bd2eb38a5f9e

See more details on using hashes here.

File details

Details for the file metrics_logger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for metrics_logger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9087d29f73620eeedf8acc0cee087c20cad6a12d317338e61bdddaf23a868f5
MD5 86359b73774a3d8287e9c54b5da8b21c
BLAKE2b-256 10a283e243cab868279af8f46f7bc0ad41e1734768a281402c5bd9abaf00f21f

See more details on using hashes here.

Supported by

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