Standardized logging for metrics capture for applications with requirements.
Project description
STScI Metrics Logger
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for metrics_logger-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9087d29f73620eeedf8acc0cee087c20cad6a12d317338e61bdddaf23a868f5 |
|
MD5 | 86359b73774a3d8287e9c54b5da8b21c |
|
BLAKE2b-256 | 10a283e243cab868279af8f46f7bc0ad41e1734768a281402c5bd9abaf00f21f |