web-metrics-process 2026.5.1__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.
- web_metrics_process-2026.5.1/PKG-INFO +25 -0
- web_metrics_process-2026.5.1/README.md +1 -0
- web_metrics_process-2026.5.1/pyproject.toml +47 -0
- web_metrics_process-2026.5.1/setup.cfg +4 -0
- web_metrics_process-2026.5.1/src/web_metrics_process/__init__.py +52 -0
- web_metrics_process-2026.5.1/src/web_metrics_process.egg-info/PKG-INFO +25 -0
- web_metrics_process-2026.5.1/src/web_metrics_process.egg-info/SOURCES.txt +8 -0
- web_metrics_process-2026.5.1/src/web_metrics_process.egg-info/dependency_links.txt +1 -0
- web_metrics_process-2026.5.1/src/web_metrics_process.egg-info/requires.txt +2 -0
- web_metrics_process-2026.5.1/src/web_metrics_process.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: web-metrics-process
|
|
3
|
+
Version: 2026.5.1
|
|
4
|
+
Summary: An easy way to add web metrics to python daemon. Update metrics from main logic in dict shared to extra web python process.
|
|
5
|
+
Author-email: itledevs <itledevs@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/itledevs/web-metrics-process
|
|
8
|
+
Project-URL: Source code, https://github.com/itledevs/web-metrics-process
|
|
9
|
+
Project-URL: Issue tracker, https://github.com/itledevs/web-metrics-process/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/itledevs/web-metrics-process/wiki
|
|
11
|
+
Keywords: web,http,process,metrics
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: fastapi
|
|
23
|
+
Requires-Dist: uvicorn
|
|
24
|
+
|
|
25
|
+
# web-metrics-process
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# web-metrics-process
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "web-metrics-process"
|
|
3
|
+
description = "An easy way to add web metrics to python daemon. Update metrics from main logic in dict shared to extra web python process."
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
|
|
6
|
+
authors = [
|
|
7
|
+
{name = "itledevs", email = "itledevs@gmail.com"},
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
license = "MIT"
|
|
11
|
+
|
|
12
|
+
# https://pypi.org/classifiers/
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.9",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
requires-python = ">= 3.9"
|
|
25
|
+
dependencies = [
|
|
26
|
+
"fastapi",
|
|
27
|
+
"uvicorn",
|
|
28
|
+
]
|
|
29
|
+
dynamic = ["version"]
|
|
30
|
+
keywords = ["web", "http", "process", "metrics"]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Repository = "https://github.com/itledevs/web-metrics-process"
|
|
34
|
+
"Source code" = "https://github.com/itledevs/web-metrics-process"
|
|
35
|
+
"Issue tracker" = "https://github.com/itledevs/web-metrics-process/issues"
|
|
36
|
+
Documentation = "https://github.com/itledevs/web-metrics-process/wiki"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.dynamic]
|
|
41
|
+
# The version number will be read from __version__ in src/web_metrics_process/__init__.py
|
|
42
|
+
version.attr = "web_metrics_process.__version__"
|
|
43
|
+
|
|
44
|
+
[build-system]
|
|
45
|
+
requires = ["setuptools>=80"]
|
|
46
|
+
build-backend = "setuptools.build_meta"
|
|
47
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
__version__ = "2026.5.1"
|
|
2
|
+
|
|
3
|
+
from multiprocessing import Process, Manager
|
|
4
|
+
from fastapi import FastAPI
|
|
5
|
+
import uvicorn
|
|
6
|
+
import random
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from string import ascii_letters, digits
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_random_str(generated_len=6):
|
|
12
|
+
"""Get random string of letters, digits """
|
|
13
|
+
password_characters = ascii_letters + digits
|
|
14
|
+
return ''.join(random.choice(password_characters) for i in range(generated_len))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def web_process(metrics_data, interface='127.0.0.1', port=8001, web_path='/metrics'):
|
|
18
|
+
app = FastAPI()
|
|
19
|
+
@app.get(web_path)
|
|
20
|
+
def metrics():
|
|
21
|
+
return metrics_data
|
|
22
|
+
uvicorn.run(app, host=interface, port=port)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class WebMetrics:
|
|
26
|
+
def __init__(self, interface='127.0.0.1', port=8001, web_path='/metrics'):
|
|
27
|
+
self.interface = interface
|
|
28
|
+
self.port = port
|
|
29
|
+
self.web_path = web_path
|
|
30
|
+
self.process = None
|
|
31
|
+
|
|
32
|
+
self.data = Manager().dict()
|
|
33
|
+
self.data['time_started'] = f'{datetime.now()}'
|
|
34
|
+
self.data['time_alive_last'] = None
|
|
35
|
+
self.data['iteration'] = 0
|
|
36
|
+
self.data['name'] = None
|
|
37
|
+
self.data['version'] = None
|
|
38
|
+
self.data['session_id'] = get_random_str(generated_len=8)
|
|
39
|
+
|
|
40
|
+
def start(self):
|
|
41
|
+
#(!) designed and valid only for linux. macOS multiprocessing is with issues, uses spawn method (forced fork got issues with uvicorn)
|
|
42
|
+
self.process = Process(target=web_process, kwargs={ 'metrics_data': self.data, 'interface': self.interface, 'port': self.port, 'web_path': self.web_path }, daemon=True)
|
|
43
|
+
self.process.start()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Example of usage in code:
|
|
47
|
+
# from web_metrics_process import WebMetrics
|
|
48
|
+
# web_metrics = WebMetrics()
|
|
49
|
+
# web_metrics.start()
|
|
50
|
+
|
|
51
|
+
## This will be available at http://<interface>:<port>/<web_path> in JSON format, default: http://127.0.0.1:8001/metrics
|
|
52
|
+
# web_metrics.data['somekey'] = 'somevalue'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: web-metrics-process
|
|
3
|
+
Version: 2026.5.1
|
|
4
|
+
Summary: An easy way to add web metrics to python daemon. Update metrics from main logic in dict shared to extra web python process.
|
|
5
|
+
Author-email: itledevs <itledevs@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/itledevs/web-metrics-process
|
|
8
|
+
Project-URL: Source code, https://github.com/itledevs/web-metrics-process
|
|
9
|
+
Project-URL: Issue tracker, https://github.com/itledevs/web-metrics-process/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/itledevs/web-metrics-process/wiki
|
|
11
|
+
Keywords: web,http,process,metrics
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: fastapi
|
|
23
|
+
Requires-Dist: uvicorn
|
|
24
|
+
|
|
25
|
+
# web-metrics-process
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/web_metrics_process/__init__.py
|
|
4
|
+
src/web_metrics_process.egg-info/PKG-INFO
|
|
5
|
+
src/web_metrics_process.egg-info/SOURCES.txt
|
|
6
|
+
src/web_metrics_process.egg-info/dependency_links.txt
|
|
7
|
+
src/web_metrics_process.egg-info/requires.txt
|
|
8
|
+
src/web_metrics_process.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
web_metrics_process
|