goatbeat-prometheus 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- goatbeat_prometheus-0.1.0/LICENSE +21 -0
- goatbeat_prometheus-0.1.0/PKG-INFO +27 -0
- goatbeat_prometheus-0.1.0/README.md +3 -0
- goatbeat_prometheus-0.1.0/pyproject.toml +48 -0
- goatbeat_prometheus-0.1.0/pyproject.toml.orig +38 -0
- goatbeat_prometheus-0.1.0/src/goatbeat/prometheus/__init__.py +3 -0
- goatbeat_prometheus-0.1.0/src/goatbeat/prometheus/metrics.py +50 -0
- goatbeat_prometheus-0.1.0/src/goatbeat/prometheus/py.typed +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Louis Midson LAJEANTY <midsonlajeanty@proton.me>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: goatbeat-prometheus
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Prometheus metrics for Goatbeat schedulers.
|
|
5
|
+
Keywords: scheduler,cron,periodic-tasks,distributed,django-tasks,leader-election
|
|
6
|
+
Author: Louis Midson LAJEANTY
|
|
7
|
+
Author-email: Louis Midson LAJEANTY <midsonlajeanty@proton.me>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Dist: goatbeat-core==0.1.0
|
|
18
|
+
Requires-Dist: prometheus-client>=0.21
|
|
19
|
+
Requires-Python: >=3.13
|
|
20
|
+
Project-URL: Homepage, https://github.com/goatlabshq/goatbeat
|
|
21
|
+
Project-URL: Documentation, https://goatlabshq.github.io/goatbeat/
|
|
22
|
+
Project-URL: Issues, https://github.com/goatlabshq/goatbeat/issues
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# goatbeat-prometheus
|
|
26
|
+
|
|
27
|
+
Prometheus metrics for Goatbeat schedulers. Part of [Goatbeat](https://github.com/goatlabshq/goatbeat).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "goatbeat-prometheus"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Prometheus metrics for Goatbeat schedulers."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
keywords = [
|
|
10
|
+
"scheduler",
|
|
11
|
+
"cron",
|
|
12
|
+
"periodic-tasks",
|
|
13
|
+
"distributed",
|
|
14
|
+
"django-tasks",
|
|
15
|
+
"leader-election",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Topic :: System :: Distributed Computing",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"goatbeat-core==0.1.0",
|
|
28
|
+
"prometheus-client>=0.21",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Louis Midson LAJEANTY"
|
|
33
|
+
email = "midsonlajeanty@proton.me"
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/goatlabshq/goatbeat"
|
|
37
|
+
Documentation = "https://goatlabshq.github.io/goatbeat/"
|
|
38
|
+
Issues = "https://github.com/goatlabshq/goatbeat/issues"
|
|
39
|
+
|
|
40
|
+
[build-system]
|
|
41
|
+
requires = ["uv_build>=0.12,<0.13"]
|
|
42
|
+
build-backend = "uv_build"
|
|
43
|
+
|
|
44
|
+
[tool.uv.build-backend]
|
|
45
|
+
module-name = "goatbeat.prometheus"
|
|
46
|
+
|
|
47
|
+
[tool.uv.sources.goatbeat-core]
|
|
48
|
+
workspace = true
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "goatbeat-prometheus"
|
|
3
|
+
version = "0.1.0" # x-release-please-version
|
|
4
|
+
description = "Prometheus metrics for Goatbeat schedulers."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Louis Midson LAJEANTY", email = "midsonlajeanty@proton.me" }]
|
|
9
|
+
requires-python = ">=3.13"
|
|
10
|
+
keywords = ["scheduler", "cron", "periodic-tasks", "distributed", "django-tasks", "leader-election"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
"Topic :: System :: Distributed Computing",
|
|
18
|
+
"Typing :: Typed",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"goatbeat-core==0.1.0", # x-release-please-version
|
|
22
|
+
"prometheus-client>=0.21",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/goatlabshq/goatbeat"
|
|
27
|
+
Documentation = "https://goatlabshq.github.io/goatbeat/"
|
|
28
|
+
Issues = "https://github.com/goatlabshq/goatbeat/issues"
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["uv_build>=0.12,<0.13"]
|
|
32
|
+
build-backend = "uv_build"
|
|
33
|
+
|
|
34
|
+
[tool.uv.build-backend]
|
|
35
|
+
module-name = "goatbeat.prometheus"
|
|
36
|
+
|
|
37
|
+
[tool.uv.sources]
|
|
38
|
+
goatbeat-core = { workspace = true }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
|
|
3
|
+
from prometheus_client import REGISTRY, CollectorRegistry, Counter, Gauge, Histogram
|
|
4
|
+
|
|
5
|
+
from goatbeat.core.execution import ExecutionStatus
|
|
6
|
+
|
|
7
|
+
# Dispatch latency spans sub-second dispatches to catch-up after hours of downtime.
|
|
8
|
+
LATENCY_BUCKETS: Final = (0.01, 0.05, 0.1, 0.5, 1, 5, 15, 60, 300, 1800, 3600)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PrometheusMetrics:
|
|
12
|
+
def __init__(self, registry: CollectorRegistry = REGISTRY) -> None:
|
|
13
|
+
self._leader = Gauge(
|
|
14
|
+
"goatbeat_leader", "1 while this scheduler holds the lease.", registry=registry
|
|
15
|
+
)
|
|
16
|
+
self._acquisitions = Counter(
|
|
17
|
+
"goatbeat_leadership_acquired",
|
|
18
|
+
"Times this scheduler became leader.",
|
|
19
|
+
registry=registry,
|
|
20
|
+
)
|
|
21
|
+
self._occurrences = Counter(
|
|
22
|
+
"goatbeat_occurrences",
|
|
23
|
+
"Occurrences by resulting status.",
|
|
24
|
+
["status"],
|
|
25
|
+
registry=registry,
|
|
26
|
+
)
|
|
27
|
+
self._latency = Histogram(
|
|
28
|
+
"goatbeat_dispatch_latency_seconds",
|
|
29
|
+
"Delay between the scheduled time and the dispatch.",
|
|
30
|
+
buckets=LATENCY_BUCKETS,
|
|
31
|
+
registry=registry,
|
|
32
|
+
)
|
|
33
|
+
self._tick = Histogram(
|
|
34
|
+
"goatbeat_tick_duration_seconds", "Duration of one scheduler tick.", registry=registry
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def leadership(self, *, is_leader: bool) -> None:
|
|
38
|
+
self._leader.set(1 if is_leader else 0)
|
|
39
|
+
|
|
40
|
+
def failover(self) -> None:
|
|
41
|
+
self._acquisitions.inc()
|
|
42
|
+
|
|
43
|
+
def occurrences(self, status: ExecutionStatus, count: int = 1) -> None:
|
|
44
|
+
self._occurrences.labels(status=status.value).inc(count)
|
|
45
|
+
|
|
46
|
+
def dispatch_latency(self, seconds: float) -> None:
|
|
47
|
+
self._latency.observe(seconds)
|
|
48
|
+
|
|
49
|
+
def tick_duration(self, seconds: float) -> None:
|
|
50
|
+
self._tick.observe(seconds)
|
|
File without changes
|