Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-prometheus-client for openSUSE:Factory checked in at 2023-05-25 23:52:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-prometheus-client (Old) and /work/SRC/openSUSE:Factory/.python-prometheus-client.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-prometheus-client" Thu May 25 23:52:21 2023 rev:9 rq:1088923 version:0.17.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-prometheus-client/python-prometheus-client.changes 2023-01-24 20:32:41.356488453 +0100 +++ /work/SRC/openSUSE:Factory/.python-prometheus-client.new.1533/python-prometheus-client.changes 2023-05-25 23:52:34.771626062 +0200 @@ -1,0 +2,8 @@ +Wed May 24 23:39:52 UTC 2023 - Matej Cepl <mc...@suse.com> + +- Update to 0.17.0: + * [ENHANCEMENT] Add additional typing. + * [BUGFIX] Fix typo in python_gc_objects_collected metadata. + * [BUGFIX] Do not include .pyc files in the build wheel. + +------------------------------------------------------------------- Old: ---- v0.16.0.tar.gz New: ---- v0.17.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-prometheus-client.spec ++++++ --- /var/tmp/diff_new_pack.jilE5I/_old 2023-05-25 23:52:35.263628950 +0200 +++ /var/tmp/diff_new_pack.jilE5I/_new 2023-05-25 23:52:35.267628974 +0200 @@ -16,10 +16,9 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-prometheus-client -Version: 0.16.0 +Version: 0.17.0 Release: 0 Summary: Python client for the Prometheus monitoring system License: Apache-2.0 @@ -30,8 +29,9 @@ # we disable testing the optional Twisted integration on older versions because that dependency tree is troublesome BuildRequires: %{python_module Twisted} %endif +BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Recommends: python-Twisted @@ -47,13 +47,19 @@ The official Python 2 and 3 client for Prometheus. %prep -%setup -q -n client_python-%{version} +%autosetup -p1 -n client_python-%{version} + +sed -i -e '1{/\/usr\/bin\/python/d}' \ + prometheus_client/__init__.py \ + prometheus_client/bridge/graphite.py \ + prometheus_client/openmetrics/exposition.py \ + prometheus_client/openmetrics/parser.py %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -62,6 +68,7 @@ %files %{python_files} %doc README.md %license LICENSE -%{python_sitelib}/* +%{python_sitelib}/prometheus_client +%{python_sitelib}/prometheus_client-%{version}*-info %changelog ++++++ v0.16.0.tar.gz -> v0.17.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/MANIFEST.in new/client_python-0.17.0/MANIFEST.in --- old/client_python-0.16.0/MANIFEST.in 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/MANIFEST.in 2023-05-24 23:16:19.000000000 +0200 @@ -1,2 +1,4 @@ -recursive-include tests * -prune tests/__pycache__ +graft tests +global-exclude *.py[cod] +prune __pycache__ +prune */__pycache__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/README.md new/client_python-0.17.0/README.md --- old/client_python-0.16.0/README.md 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/README.md 2023-05-24 23:16:19.000000000 +0200 @@ -416,6 +416,55 @@ Visit http://localhost:8000/metrics to see the metrics +#### FastAPI + Gunicorn + +To use Prometheus with [FastAPI](https://fastapi.tiangolo.com/) and [Gunicorn](https://gunicorn.org/) we need to serve metrics through a Prometheus ASGI application. + +Save the snippet below in a `myapp.py` file + +```python +from fastapi import FastAPI +from prometheus_client import make_asgi_app + +# Create app +app = FastAPI(debug=False) + +# Add prometheus asgi middleware to route /metrics requests +metrics_app = make_asgi_app() +app.mount("/metrics", metrics_app) +``` + +For Multiprocessing support, use this modified code snippet. Full multiprocessing intstructions are provided [here](https://github.com/prometheus/client_python#multiprocess-mode-eg-gunicorn). + +```python +from fastapi import FastAPI +from prometheus_client import make_asgi_app + +app = FastAPI(debug=False) + +# Using multiprocess collector for registry +def make_metrics_app(): + registry = CollectorRegistry() + multiprocess.MultiProcessCollector(registry) + return make_asgi_app(registry=registry) + + +metrics_app = make_metrics_app() +app.mount("/metrics", metrics_app) +``` + +Run the example web application like this + +```bash +# Install gunicorn if you do not have it +pip install gunicorn +# If using multiple workers, add `--workers n` parameter to the line below +gunicorn -b 127.0.0.1:8000 myapp:app -k uvicorn.workers.UvicornWorker +``` + +Visit http://localhost:8000/metrics to see the metrics + + ### Node exporter textfile collector The [textfile collector](https://github.com/prometheus/node_exporter#textfile-collector) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/prometheus_client/context_managers.py new/client_python-0.17.0/prometheus_client/context_managers.py --- old/client_python-0.16.0/prometheus_client/context_managers.py 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/prometheus_client/context_managers.py 2023-05-24 23:16:19.000000000 +0200 @@ -46,7 +46,7 @@ def __exit__(self, typ, value, traceback): self._gauge.dec() - def __call__(self, f): + def __call__(self, f: "F") -> "F": def wrapped(func, *args, **kwargs): with self: return func(*args, **kwargs) @@ -75,7 +75,7 @@ def labels(self, *args, **kw): self._metric = self._metric.labels(*args, **kw) - def __call__(self, f): + def __call__(self, f: "F") -> "F": def wrapped(func, *args, **kwargs): # Obtaining new instance of timer every time # ensures thread safety and reentrancy. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/prometheus_client/gc_collector.py new/client_python-0.17.0/prometheus_client/gc_collector.py --- old/client_python-0.16.0/prometheus_client/gc_collector.py 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/prometheus_client/gc_collector.py 2023-05-24 23:16:19.000000000 +0200 @@ -22,7 +22,7 @@ ) uncollectable = CounterMetricFamily( 'python_gc_objects_uncollectable', - 'Uncollectable object found during GC', + 'Uncollectable objects found during GC', labels=['generation'], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/prometheus_client/parser.py new/client_python-0.17.0/prometheus_client/parser.py --- old/client_python-0.16.0/prometheus_client/parser.py 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/prometheus_client/parser.py 2023-05-24 23:16:19.000000000 +0200 @@ -1,11 +1,12 @@ import io as StringIO import re +from typing import Dict, Iterable, List, Match, Optional, TextIO, Tuple from .metrics_core import Metric from .samples import Sample -def text_string_to_metric_families(text): +def text_string_to_metric_families(text: str) -> Iterable[Metric]: """Parse Prometheus text format from a unicode string. See text_fd_to_metric_families. @@ -20,7 +21,7 @@ } -def replace_escape_sequence(match): +def replace_escape_sequence(match: Match[str]) -> str: return ESCAPE_SEQUENCES[match.group(0)] @@ -28,15 +29,15 @@ ESCAPING_RE = re.compile(r'\\[\\n"]') -def _replace_help_escaping(s): +def _replace_help_escaping(s: str) -> str: return HELP_ESCAPING_RE.sub(replace_escape_sequence, s) -def _replace_escaping(s): +def _replace_escaping(s: str) -> str: return ESCAPING_RE.sub(replace_escape_sequence, s) -def _is_character_escaped(s, charpos): +def _is_character_escaped(s: str, charpos: int) -> bool: num_bslashes = 0 while (charpos > num_bslashes and s[charpos - 1 - num_bslashes] == '\\'): @@ -44,8 +45,8 @@ return num_bslashes % 2 == 1 -def _parse_labels(labels_string): - labels = {} +def _parse_labels(labels_string: str) -> Dict[str, str]: + labels: Dict[str, str] = {} # Return if we don't have valid labels if "=" not in labels_string: return labels @@ -95,7 +96,7 @@ # If we have multiple values only consider the first -def _parse_value_and_timestamp(s): +def _parse_value_and_timestamp(s: str) -> Tuple[float, Optional[float]]: s = s.lstrip() separator = " " if separator not in s: @@ -108,7 +109,7 @@ return value, timestamp -def _parse_sample(text): +def _parse_sample(text: str) -> Sample: # Detect the labels in the text try: label_start, label_end = text.index("{"), text.rindex("}") @@ -133,7 +134,7 @@ return Sample(name, {}, value, timestamp) -def text_fd_to_metric_families(fd): +def text_fd_to_metric_families(fd: TextIO) -> Iterable[Metric]: """Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, @@ -145,10 +146,10 @@ name = '' documentation = '' typ = 'untyped' - samples = [] + samples: List[Sample] = [] allowed_names = [] - def build_metric(name, documentation, typ, samples): + def build_metric(name: str, documentation: str, typ: str, samples: List[Sample]) -> Metric: # Munge counters into OpenMetrics representation # used internally. if typ == 'counter': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/client_python-0.16.0/setup.py new/client_python-0.17.0/setup.py --- old/client_python-0.16.0/setup.py 2023-01-23 23:05:11.000000000 +0100 +++ new/client_python-0.17.0/setup.py 2023-05-24 23:16:19.000000000 +0200 @@ -8,7 +8,7 @@ setup( name="prometheus_client", - version="0.16.0", + version="0.17.0", author="Brian Brazil", author_email="brian.bra...@robustperception.io", description="Python client for the Prometheus monitoring system.",