Skip to content

Commit 909f137

Browse files
authored
Merge pull request #18 from faucetsdn/v0.22.0
Upgrade python3-prometheus-client to v0.22.0
2 parents 8753ddc + bce5655 commit 909f137

File tree

226 files changed

+2285
-840
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+2285
-840
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ workflows:
7575
matrix:
7676
parameters:
7777
python:
78-
- "3.8.18"
7978
- "3.9.18"
8079
- "3.10"
8180
- "3.11"
8281
- "3.12"
82+
- "3.13"
8383
- test_nooptionals:
8484
matrix:
8585
parameters:
@@ -89,4 +89,4 @@ workflows:
8989
matrix:
9090
parameters:
9191
python:
92-
- "3.8"
92+
- "3.9"

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Section: python
66
Priority: optional
77
Build-Depends: debhelper (>= 11),
88
Build-Depends-Indep: dh-python,
9+
pybuild-plugin-pyproject,
910
python3-all,
1011
python3-decorator (>= 4.0.10),
1112
python3-pytest,

debian/patches/0001-import-unvendorized-decorator.patch

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ Index: python3-prometheus-client/tests/test_core.py
2222
===================================================================
2323
--- python3-prometheus-client.orig/tests/test_core.py
2424
+++ python3-prometheus-client/tests/test_core.py
25-
@@ -12,9 +12,16 @@ from prometheus_client.core import (
25+
@@ -12,12 +12,19 @@ from prometheus_client.core import (
2626
HistogramMetricFamily, Info, InfoMetricFamily, Metric, Sample,
2727
StateSetMetricFamily, Summary, SummaryMetricFamily, UntypedMetricFamily,
2828
)
2929
-from prometheus_client.decorator import getargspec
3030
from prometheus_client.metrics import _get_use_created
31+
from prometheus_client.validation import (
32+
disable_legacy_validation, enable_legacy_validation,
33+
)
3134

3235
+from inspect import getfullargspec
3336
+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Index: python3-prometheus-client/pyproject.toml
2+
===================================================================
3+
--- python3-prometheus-client.orig/pyproject.toml
4+
+++ python3-prometheus-client/pyproject.toml
5+
@@ -47,3 +47,17 @@ Documentation = "https://prometheus.gith
6+
7+
[tool.setuptools.package-data]
8+
prometheus_client = ['py.typed']
9+
+
10+
+[tool.setuptools.data-files]
11+
+"tests" = [
12+
+ "tests/certs/*",
13+
+ "tests/proc/stat",
14+
+ "tests/proc/584/*",
15+
+ "tests/proc/26231/limits",
16+
+ "tests/proc/26231/stat",
17+
+ "tests/proc/26231/fd/*",
18+
+]
19+
+
20+
+[tool.setuptools.packages.find]
21+
+where = ["."]
22+
+exclude = ["debian"]

debian/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
0001-import-unvendorized-decorator.patch
2+
0002-Update-pyproject.toml.patch

docs/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.hugo_build.lock
1+
.hugo_build.lock

docs/README.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
Docs
2-
----
1+
# Docs
32

43
This directory contains [hugo](https://gohugo.io) documentation to be published in Github pages.
54

6-
Run Locally
7-
-----------
5+
## Dependencies
86

9-
```
7+
- [Geekdocs v1.5.0](https://github.com/thegeeklab/hugo-geekdoc/releases/tag/v1.5.0)
8+
- [Hugo v0.145.0](https://github.com/gohugoio/hugo/releases/tag/v0.145.0)
9+
10+
## Run Locally
11+
12+
To serve the documentation locally, run the following command:
13+
14+
```shell
1015
hugo server -D
1116
```
1217

1318
This will serve the docs on [http://localhost:1313](http://localhost:1313).
1419

15-
Deploy to Github Pages
16-
----------------------
17-
18-
Changes to the `main` branch will be deployed automatically with Github actions.
19-
20-
Update Geekdocs
21-
---------------
20+
## Update Geekdocs
2221

2322
The docs use the [Geekdocs](https://geekdocs.de/) theme. The theme is checked in to Github in the `./docs/themes/hugo-geekdoc/` folder. To update [Geekdocs](https://geekdocs.de/), remove the current folder and create a new one with the latest [release](https://github.com/thegeeklab/hugo-geekdoc/releases). There are no local modifications in `./docs/themes/hugo-geekdoc/`.
2423

25-
Notes
26-
-----
27-
28-
Here's how the initial `docs/` folder was set up:
29-
30-
```
31-
hugo new site docs
32-
cd docs/
24+
```shell
25+
rm -rf ./docs/themes/hugo-geekdoc
3326
mkdir -p themes/hugo-geekdoc/
34-
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/download/v0.41.1/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
27+
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/latest/download/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
3528
```
3629

37-
Create the initial `hugo.toml` file as described in [https://geekdocs.de/usage/getting-started/](https://geekdocs.de/usage/getting-started/).
30+
## Deploy to Github Pages
31+
32+
Changes to the `master` branch will be deployed automatically with Github actions.

docs/content/_index.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
---
2-
title: "client_python"
2+
title: client_python
3+
weight: 1
34
---
45

5-
This is the documentation for the [Prometheus Python client library](https://github.com/prometheus/client_python).
6+
This tutorial shows the quickest way to get started with the Prometheus Python library.
7+
8+
**One**: Install the client:
9+
10+
```shell
11+
pip install prometheus-client
12+
```
13+
14+
**Two**: Paste the following into a Python interpreter:
15+
16+
```python
17+
from prometheus_client import start_http_server, Summary
18+
import random
19+
import time
20+
21+
# Create a metric to track time spent and requests made.
22+
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
23+
24+
# Decorate function with metric.
25+
@REQUEST_TIME.time()
26+
def process_request(t):
27+
"""A dummy function that takes some time."""
28+
time.sleep(t)
29+
30+
if __name__ == '__main__':
31+
# Start up the server to expose the metrics.
32+
start_http_server(8000)
33+
# Generate some requests.
34+
while True:
35+
process_request(random.random())
36+
```
37+
38+
**Three**: Visit [http://localhost:8000/](http://localhost:8000/) to view the metrics.
39+
40+
From one easy to use decorator you get:
41+
42+
* `request_processing_seconds_count`: Number of times this function was called.
43+
* `request_processing_seconds_sum`: Total amount of time spent in this function.
44+
45+
Prometheus's `rate` function allows calculation of both requests per second,
46+
and latency over time from this data.
47+
48+
In addition if you're on Linux the `process` metrics expose CPU, memory and
49+
other information about the process for free!

docs/content/exporting/pushgateway.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ weight: 3
55

66
The [Pushgateway](https://github.com/prometheus/pushgateway)
77
allows ephemeral and batch jobs to expose their metrics to Prometheus.
8+
Since Prometheus may not be able to scrape such a target, the targets can
9+
push their metrics to a separate instance of the Pushgateway,
10+
which then exposes these metrics to Prometheus.
811

912
```python
1013
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
@@ -18,16 +21,20 @@ push_to_gateway('localhost:9091', job='batchA', registry=registry)
1821
A separate registry is used, as the default registry may contain other metrics
1922
such as those from the Process Collector.
2023

21-
Pushgateway functions take a grouping key. `push_to_gateway` replaces metrics
22-
with the same grouping key, `pushadd_to_gateway` only replaces metrics with the
23-
same name and grouping key and `delete_from_gateway` deletes metrics with the
24-
given job and grouping key. See the
24+
Pushgateway functions take a grouping key.
25+
1. `push_to_gateway` replaces metrics
26+
with the same grouping key.
27+
2. `pushadd_to_gateway` only replaces metrics with the
28+
same name and grouping key.
29+
3. `delete_from_gateway` deletes metrics with the
30+
given job and grouping key.
31+
4. `instance_ip_grouping_key` returns a grouping key with the instance label set
32+
to the host's IP address.
33+
34+
See the
2535
[Pushgateway documentation](https://github.com/prometheus/pushgateway/blob/master/README.md)
2636
for more information.
2737

28-
`instance_ip_grouping_key` returns a grouping key with the instance label set
29-
to the host's IP address.
30-
3138
# Handlers for authentication
3239

3340
If the push gateway you are connecting to is protected with HTTP Basic Auth,

docs/content/getting-started/_index.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/content/getting-started/three-step-demo.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/content/multiprocess/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This comes with a number of limitations:
1414
- Registering metrics to a registry later used by a `MultiProcessCollector`
1515
may cause duplicate metrics to be exported
1616
- Custom collectors do not work (e.g. cpu and memory metrics)
17+
- Gauges cannot use `set_function`
1718
- Info and Enum metrics do not work
1819
- The pushgateway cannot be used
1920
- Gauges cannot use the `pid` label

0 commit comments

Comments
 (0)