Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ workflows:
matrix:
parameters:
python:
- "3.8.18"
- "3.9.18"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- test_nooptionals:
matrix:
parameters:
Expand All @@ -89,4 +89,4 @@ workflows:
matrix:
parameters:
python:
- "3.8"
- "3.9"
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Section: python
Priority: optional
Build-Depends: debhelper (>= 11),
Build-Depends-Indep: dh-python,
pybuild-plugin-pyproject,
python3-all,
python3-decorator (>= 4.0.10),
python3-pytest,
Expand Down
5 changes: 4 additions & 1 deletion debian/patches/0001-import-unvendorized-decorator.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ Index: python3-prometheus-client/tests/test_core.py
===================================================================
--- python3-prometheus-client.orig/tests/test_core.py
+++ python3-prometheus-client/tests/test_core.py
@@ -12,9 +12,16 @@ from prometheus_client.core import (
@@ -12,12 +12,19 @@ from prometheus_client.core import (
HistogramMetricFamily, Info, InfoMetricFamily, Metric, Sample,
StateSetMetricFamily, Summary, SummaryMetricFamily, UntypedMetricFamily,
)
-from prometheus_client.decorator import getargspec
from prometheus_client.metrics import _get_use_created
from prometheus_client.validation import (
disable_legacy_validation, enable_legacy_validation,
)

+from inspect import getfullargspec
+
Expand Down
22 changes: 22 additions & 0 deletions debian/patches/0002-Update-pyproject.toml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Index: python3-prometheus-client/pyproject.toml
===================================================================
--- python3-prometheus-client.orig/pyproject.toml
+++ python3-prometheus-client/pyproject.toml
@@ -47,3 +47,17 @@ Documentation = "https://prometheus.gith

[tool.setuptools.package-data]
prometheus_client = ['py.typed']
+
+[tool.setuptools.data-files]
+"tests" = [
+ "tests/certs/*",
+ "tests/proc/stat",
+ "tests/proc/584/*",
+ "tests/proc/26231/limits",
+ "tests/proc/26231/stat",
+ "tests/proc/26231/fd/*",
+]
+
+[tool.setuptools.packages.find]
+where = ["."]
+exclude = ["debian"]
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0001-import-unvendorized-decorator.patch
0002-Update-pyproject.toml.patch
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.hugo_build.lock
.hugo_build.lock
39 changes: 17 additions & 22 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
Docs
----
# Docs

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

Run Locally
-----------
## Dependencies

```
- [Geekdocs v1.5.0](https://github.com/thegeeklab/hugo-geekdoc/releases/tag/v1.5.0)
- [Hugo v0.145.0](https://github.com/gohugoio/hugo/releases/tag/v0.145.0)

## Run Locally

To serve the documentation locally, run the following command:

```shell
hugo server -D
```

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

Deploy to Github Pages
----------------------

Changes to the `main` branch will be deployed automatically with Github actions.

Update Geekdocs
---------------
## Update Geekdocs

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/`.

Notes
-----

Here's how the initial `docs/` folder was set up:

```
hugo new site docs
cd docs/
```shell
rm -rf ./docs/themes/hugo-geekdoc
mkdir -p themes/hugo-geekdoc/
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
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/latest/download/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
```

Create the initial `hugo.toml` file as described in [https://geekdocs.de/usage/getting-started/](https://geekdocs.de/usage/getting-started/).
## Deploy to Github Pages

Changes to the `master` branch will be deployed automatically with Github actions.
48 changes: 46 additions & 2 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
---
title: "client_python"
title: client_python
weight: 1
---

This is the documentation for the [Prometheus Python client library](https://github.com/prometheus/client_python).
This tutorial shows the quickest way to get started with the Prometheus Python library.

**One**: Install the client:

```shell
pip install prometheus-client
```

**Two**: Paste the following into a Python interpreter:

```python
from prometheus_client import start_http_server, Summary
import random
import time

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

# Decorate function with metric.
@REQUEST_TIME.time()
def process_request(t):
"""A dummy function that takes some time."""
time.sleep(t)

if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
# Generate some requests.
while True:
process_request(random.random())
```

**Three**: Visit [http://localhost:8000/](http://localhost:8000/) to view the metrics.

From one easy to use decorator you get:

* `request_processing_seconds_count`: Number of times this function was called.
* `request_processing_seconds_sum`: Total amount of time spent in this function.

Prometheus's `rate` function allows calculation of both requests per second,
and latency over time from this data.

In addition if you're on Linux the `process` metrics expose CPU, memory and
other information about the process for free!
21 changes: 14 additions & 7 deletions docs/content/exporting/pushgateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ weight: 3

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

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

Pushgateway functions take a grouping key. `push_to_gateway` replaces metrics
with the same grouping key, `pushadd_to_gateway` only replaces metrics with the
same name and grouping key and `delete_from_gateway` deletes metrics with the
given job and grouping key. See the
Pushgateway functions take a grouping key.
1. `push_to_gateway` replaces metrics
with the same grouping key.
2. `pushadd_to_gateway` only replaces metrics with the
same name and grouping key.
3. `delete_from_gateway` deletes metrics with the
given job and grouping key.
4. `instance_ip_grouping_key` returns a grouping key with the instance label set
to the host's IP address.

See the
[Pushgateway documentation](https://github.com/prometheus/pushgateway/blob/master/README.md)
for more information.

`instance_ip_grouping_key` returns a grouping key with the instance label set
to the host's IP address.

# Handlers for authentication

If the push gateway you are connecting to is protected with HTTP Basic Auth,
Expand Down
4 changes: 0 additions & 4 deletions docs/content/getting-started/_index.md

This file was deleted.

48 changes: 0 additions & 48 deletions docs/content/getting-started/three-step-demo.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/content/multiprocess/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This comes with a number of limitations:
- Registering metrics to a registry later used by a `MultiProcessCollector`
may cause duplicate metrics to be exported
- Custom collectors do not work (e.g. cpu and memory metrics)
- Gauges cannot use `set_function`
- Info and Enum metrics do not work
- The pushgateway cannot be used
- Gauges cannot use the `pid` label
Expand Down
Loading