From 4f99c0e94153e93df7851f32bab16c3ed3969daa Mon Sep 17 00:00:00 2001 From: Stefan Kecskes Date: Wed, 7 Feb 2024 21:06:25 +0000 Subject: [PATCH 1/2] refresh repository --- .github/workflows/ci.yaml | 2 +- CONTRIBUTING.md | 13 +++++++------ LICENSE | 2 +- README.md | 7 ++++--- faustprometheus/monitor.py | 6 ++++-- setup.py | 8 ++++---- tests/test_monitor.py | 9 +++++---- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 424e20d..d30e39c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.7, 3.8, 3.9 ] + python-version: [ 3.7, 3.8, 3.9, 3.10 ] steps: - uses: actions/checkout@v2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a587bbd..e324933 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,14 @@ # Contributing to Faust-Prometheus -Documentation for Faust-Prometheus is available in the Faust-Prometheus [repo]( https://github.com/woodmac/Faust-Prometheus/README.md ) +Documentation for Faust-Prometheus is available in the Faust-Prometheus [repo]( https://github.com/skecskes/faust-prometheus/README.md ) -The Faust-Prometheus team is following a very simple branching model. We use [master](https://github.com/woodmac/Faust-Prometheus/tree/master) as the production branch and all other branches for features or bugs. We do not maintain a dev only branch, staging, etc. +The Faust-Prometheus team is following a very simple branching model. We use [master](https://github.com/skecskes/faust-prometheus/tree/master) as the production branch and all other branches for features or bugs. We do not maintain a dev only branch, staging, etc. -Contributions will be accepted to the [master](https://github.com/woodmac/Faust-Prometheus/tree/master) only. +Contributions will be accepted to the [master](https://github.com/skecskes/faust-prometheus/tree/master) only. ## How to provide a pull request/patch for a new feature -1. If it is a major feature, please create an [Issue]( https://github.com/woodmac/Faust-Prometheus/issues ) and discuss it with the project leaders. +1. If it is a major feature, please create an [Issue]( https://github.com/skecskes/faust-prometheus/issues ) and discuss it with the project leaders. 2. If in step 1 you get an acknowledgement from the project leaders, use the following procedure to submit a pull request: @@ -25,8 +25,9 @@ Contributions will be accepted to the [master](https://github.com/woodmac/Faust- f. We'll review your pull request and merge when approved! -For minor fixes just create a patch to the [master]( https://github.com/woodmac/Faust-Prometheus/tree/master ) branch on Github. +For minor fixes just create a patch to the [master]( https://github.com/skecskes/faust-prometheus/tree/master ) branch +on GitHub. ## Questions -If you have questions or want to report a bug please create an [Issue]( https://github.com/woodmac/Faust-Prometheus/issues) +If you have questions or want to report a bug please create an [Issue]( https://github.com/skecskes/faust-prometheus/issues) diff --git a/LICENSE b/LICENSE index 116333d..21c4f0e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020, Wood Mackenzie Ltd. +Copyright (c) 2023, Stefan Kecskes All rights reserved. Faust Prometheus is licensed under The BSD License (3 Clause, also known as diff --git a/README.md b/README.md index dbba463..24a6c87 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # Faust Prometheus -This library uses sensors of Faust. Those sensors are events based. Our monitor implements that interface and hooks some actions when those events happen. That allows us to create our own prometheus `Counters`, `Gauges` and `Histograms`. +This library uses sensors of Faust. Those sensors are events based. Our monitor implements that interface and hooks some +actions when those events happen. That allows us to create our own prometheus `Counters`, `Gauges` and `Histograms`. I created some predefined metrics, but we can expand on them in the future. ## Installation -To use this library in your faust project just add `faustprometheus` or install it through pip: +To use this library in your faust project just add `faust-prometheus` or install it through pip: - pip install faustprometheus + pip install faust-prometheus ## Usage diff --git a/faustprometheus/monitor.py b/faustprometheus/monitor.py index 80b221d..a8d3813 100644 --- a/faustprometheus/monitor.py +++ b/faustprometheus/monitor.py @@ -73,7 +73,8 @@ def __init__(self, app: AppT, pm_config: PrometheusMonitorConfig = None, **kwarg # TODO: for now turn off default python garbage collection metrics. # If needed later, look into implementing them with labels - def _python_gc_metrics(self, remove: bool = True): + @staticmethod + def _python_gc_metrics(remove: bool = True): collectors = REGISTRY._names_to_collectors.values() for name in list(collectors): with suppress(KeyError): @@ -100,7 +101,8 @@ def on_stream_event_in(self, tp: TP, offset: int, stream: StreamT, return state - def _normalize(self, name: str, + @staticmethod + def _normalize(name: str, *, pattern: typing.Pattern = RE_NORMALIZE, substitution: str = RE_NORMALIZE_SUBSTITUTION) -> str: diff --git a/setup.py b/setup.py index 76ee71f..db6df86 100644 --- a/setup.py +++ b/setup.py @@ -7,14 +7,14 @@ long_description = fh.read() setup( - name='faustprometheus', + name='faust-prometheus', version="0.0.6", - author='Wood Mackenzie', + author='Stefan Kecskes', author_email='mr.kecskes@gmail.com', - description="WoodMac's Faust Prometheus Library", + description="Prometheus metrics for Faust stream processing framework", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/woodmac/faust-prometheus", + url="https://github.com/skecskes/faust-prometheus", packages=find_packages(), classifiers=[ "Programming Language :: Python :: 3.6", diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 75f5f35..3756a01 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -13,10 +13,11 @@ class TestPrometheusMonitor: - def time(self): - timefun = Mock(name='time()') - timefun.return_value = 101.1 - return timefun + @staticmethod + def time(): + time_fun = Mock(name='time()') + time_fun.return_value = 101.1 + return time_fun @patch.object(PrometheusMonitor, 'expose_metrics') def prometheus_client(self, app, time=None): From 5e26662fb370370ce15b4a9871d8130a2953a0dc Mon Sep 17 00:00:00 2001 From: Stefan Kecskes Date: Wed, 7 Feb 2024 21:14:21 +0000 Subject: [PATCH 2/2] fix ci --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d30e39c..424e20d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.7, 3.8, 3.9, 3.10 ] + python-version: [ 3.7, 3.8, 3.9 ] steps: - uses: actions/checkout@v2