Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 692aeee

Browse filesBrowse files
chore(deps): update minor updates (#200)
* chore(deps): update minor updates * fix(deps): prometheus_client 0.16 compat Pass through extra arguments to mmap_key after prometheus/client_python#804 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jakob van Santen <jvansanten@gmail.com>
1 parent 50943d8 commit 692aeee
Copy full SHA for 692aeee

File tree

Expand file treeCollapse file tree

4 files changed

+18
-15
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+18
-15
lines changed

‎.github/workflows/docs.yml

Copy file name to clipboardExpand all lines: .github/workflows/docs.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: |
2727
poetry run sphinx-build docs/sphinx public
2828
- name: Deploy
29-
uses: peaceiris/actions-gh-pages@v3.9.1
29+
uses: peaceiris/actions-gh-pages@v3.9.2
3030
with:
3131
github_token: ${{ secrets.GITHUB_TOKEN }}
3232
publish_dir: ./public

‎ampel/metrics/prometheus.py

Copy file name to clipboardExpand all lines: ampel/metrics/prometheus.py
+12-9Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
import glob
3333
import os
3434
import tempfile
35+
from typing import Collection
3536

3637
from prometheus_client import (
38+
Metric,
3739
CollectorRegistry,
3840
core,
3941
generate_latest,
@@ -55,28 +57,29 @@ def collect_metrics():
5557
return generate_latest(registry)
5658

5759

58-
def prometheus_setup_worker(labels=None):
60+
def prometheus_setup_worker(labels: None | dict[str,str] = None) -> None:
5961
"""
6062
Monkey-patch mmap_key and ValueClass to add implicit labels. This must be
6163
done before any metrics are instantiated.
6264
"""
63-
if labels:
65+
if labels is not None:
6466
from prometheus_client import values
6567

66-
def mmap_key(metric_name, name, labelnames, labelvalues):
68+
def mmap_key(metric_name: str, name: str, labelnames: list[str], labelvalues: list[str], help_text: str) -> str:
6769
return mmap_dict.mmap_key(
6870
metric_name,
6971
name,
70-
tuple(labels.keys()) + labelnames,
71-
tuple(labels.values()) + labelvalues,
72+
list(labels.keys()) + list(labelnames) if labels else labelnames,
73+
list(labels.values()) + list(labelvalues) if labels else labelvalues,
74+
help_text,
7275
)
7376

7477
values.mmap_key = mmap_key
7578
# synthesize a new ValueClass (captures mmap_key)
7679
values.ValueClass = values.get_value_class()
7780

7881

79-
def prometheus_cleanup_worker(pid):
82+
def prometheus_cleanup_worker(pid: int) -> None:
8083
"""
8184
Aggregate dead worker's metrics into a single archive file, preventing
8285
collection time from growing without bound as pointed out in
@@ -109,7 +112,7 @@ def prometheus_cleanup_worker(pid):
109112
collect_paths = paths + archive_paths
110113
collector = multiprocess.MultiProcessCollector(None)
111114

112-
metrics = collector.merge(collect_paths, accumulate=False)
115+
metrics: Collection[Metric] = collector.merge(collect_paths, accumulate=False)
113116

114117
tmp_histogram = tempfile.NamedTemporaryFile(delete=False)
115118
tmp_counter = tempfile.NamedTemporaryFile(delete=False)
@@ -124,7 +127,7 @@ def prometheus_cleanup_worker(pid):
124127
os.unlink(path)
125128

126129

127-
def write_metrics(metrics, histogram_file, counter_file):
130+
def write_metrics(metrics: Collection[Metric], histogram_file: str, counter_file: str) -> None:
128131

129132
histograms = mmap_dict.MmapedDict(histogram_file)
130133
counters = mmap_dict.MmapedDict(counter_file)
@@ -142,7 +145,7 @@ def write_metrics(metrics, histogram_file, counter_file):
142145
# prometheus_client 0.4+ adds extra fields
143146
name, labels, value = sample[:3]
144147
key = mmap_dict.mmap_key(
145-
metric.name, name, tuple(labels), tuple(labels.values()),
148+
metric.name, name, list(labels.keys()), list(labels.values()), metric.documentation,
146149
)
147150
sink.write_value(key, value)
148151
finally:

‎poetry.lock

Copy file name to clipboardExpand all lines: poetry.lock
+4-4Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml

Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pydantic = "^1.9.0"
5151
sjcl = "^0.2.1"
5252
schedule = "^1.0.0"
5353
yq = "^3.0.0"
54-
prometheus-client = ">=0.15,<0.16"
54+
prometheus-client = ">=0.16,<0.17"
5555
xxhash = "^3.0.0"
5656
psutil = "^5.8.0"
5757
appdirs = "^1.4.4"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.