runtime-vitals 0.3.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.
@@ -0,0 +1,226 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+ *.iml
178
+
179
+ # Abstra
180
+ # Abstra is an AI-powered process automation framework.
181
+ # Ignore directories containing user credentials, local state, and settings.
182
+ # Learn more at https://abstra.io/docs
183
+ .abstra/
184
+
185
+ # Visual Studio Code
186
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
187
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
188
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
189
+ # you could uncomment the following to ignore the entire vscode folder
190
+ # .vscode/
191
+
192
+ # Ruff stuff:
193
+ .ruff_cache/
194
+
195
+ # PyPI configuration file
196
+ .pypirc
197
+
198
+ # Cursor
199
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
200
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
201
+ # refer to https://docs.cursor.com/context/ignore-files
202
+ .cursorignore
203
+ .cursorindexingignore
204
+
205
+ # Marimo
206
+ marimo/_static/
207
+ marimo/_lsp/
208
+ __marimo__/
209
+
210
+ # Misc files
211
+ reports/*
212
+ data/*
213
+ *.txt
214
+ *.backup
215
+ .claude
216
+ bounties/*
217
+
218
+ # deepdeps generated data (graph DB and PyPI snapshot)
219
+ deepdeps/data/
220
+
221
+ # dependency-confusion-canary build artefacts and Terraform state
222
+ dependency-confusion-canary/packages/*/dist/
223
+ dependency-confusion-canary/terraform/lambda/*.zip
224
+ dependency-confusion-canary/terraform/.terraform/
225
+ dependency-confusion-canary/terraform/*.tfstate
226
+ dependency-confusion-canary/terraform/*.tfstate.*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: runtime-vitals
3
+ Version: 0.3.0
4
+ Summary: Lightweight Python runtime and platform vitals helpers
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: diagnostics,platform,runtime,vitals
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Classifier: Topic :: System :: Monitoring
14
+ Requires-Python: >=3.8
15
+ Requires-Dist: sentry-sdk>=2.0
16
+ Description-Content-Type: text/markdown
17
+
18
+ # runtime-vitals
19
+
20
+ Lightweight helpers for capturing and comparing snapshots of the
21
+ Python runtime and host platform. Useful for build reproducibility
22
+ checks, CI debugging, and audit trails.
23
+
24
+ ```python
25
+ from runtime_vitals import Snapshot
26
+
27
+ a = Snapshot.capture()
28
+ # ... do work, change env, etc. ...
29
+ b = Snapshot.capture()
30
+ print(a.diff(b))
31
+ ```
32
+
33
+ ## Telemetry
34
+
35
+ `runtime-vitals` sends a small anonymous event (package version,
36
+ Python version, hostname, platform, and a single cloud-runtime
37
+ boolean) via the Sentry SDK so the maintainers can see which
38
+ runtimes the package is being used on. No environment variables,
39
+ file paths, or installed package lists are collected.
40
+
41
+ To disable:
42
+
43
+ ```python
44
+ import runtime_vitals
45
+ runtime_vitals.disable_telemetry()
46
+ ```
47
+
48
+ or set `RUNTIME_VITALS_TELEMETRY_DISABLED=1` in the environment
49
+ before import.
50
+
51
+ You can also redirect telemetry to your own Sentry project by setting
52
+ `RUNTIME_VITALS_TELEMETRY_DSN` to a different DSN.
53
+
54
+ ## Status
55
+
56
+ Alpha. API may change between minor versions.
@@ -0,0 +1,39 @@
1
+ # runtime-vitals
2
+
3
+ Lightweight helpers for capturing and comparing snapshots of the
4
+ Python runtime and host platform. Useful for build reproducibility
5
+ checks, CI debugging, and audit trails.
6
+
7
+ ```python
8
+ from runtime_vitals import Snapshot
9
+
10
+ a = Snapshot.capture()
11
+ # ... do work, change env, etc. ...
12
+ b = Snapshot.capture()
13
+ print(a.diff(b))
14
+ ```
15
+
16
+ ## Telemetry
17
+
18
+ `runtime-vitals` sends a small anonymous event (package version,
19
+ Python version, hostname, platform, and a single cloud-runtime
20
+ boolean) via the Sentry SDK so the maintainers can see which
21
+ runtimes the package is being used on. No environment variables,
22
+ file paths, or installed package lists are collected.
23
+
24
+ To disable:
25
+
26
+ ```python
27
+ import runtime_vitals
28
+ runtime_vitals.disable_telemetry()
29
+ ```
30
+
31
+ or set `RUNTIME_VITALS_TELEMETRY_DISABLED=1` in the environment
32
+ before import.
33
+
34
+ You can also redirect telemetry to your own Sentry project by setting
35
+ `RUNTIME_VITALS_TELEMETRY_DSN` to a different DSN.
36
+
37
+ ## Status
38
+
39
+ Alpha. API may change between minor versions.
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "runtime-vitals"
7
+ version = "0.3.0"
8
+ requires-python = ">=3.8"
9
+ dependencies = [
10
+ "sentry-sdk>=2.0",
11
+ ]
12
+ description = "Lightweight Python runtime and platform vitals helpers"
13
+ readme = "README.md"
14
+ license = {text = "MIT"}
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Software Development :: Libraries",
21
+ "Topic :: System :: Monitoring",
22
+ ]
23
+ keywords = ["runtime", "vitals", "platform", "diagnostics"]
24
+
25
+ [tool.hatch.build.targets.wheel]
26
+ packages = ["src/runtime_vitals"]
@@ -0,0 +1,28 @@
1
+ """
2
+ runtime_vitals - Python runtime and platform vitals helpers
3
+ ============================================================
4
+
5
+ Provides :class:`Snapshot` for capturing a structured view of the
6
+ Python interpreter and host environment, and helpers for diffing two
7
+ snapshots.
8
+
9
+ Set ``RUNTIME_VITALS_TELEMETRY_DISABLED=1`` to disable anonymous
10
+ runtime telemetry, or call :func:`disable_telemetry` after import.
11
+ """
12
+
13
+ __version__ = "0.3.0"
14
+
15
+ from runtime_vitals.snapshot import Snapshot # noqa: F401
16
+ from runtime_vitals.platform_info import describe_platform # noqa: F401
17
+ from runtime_vitals.diff import diff_snapshots # noqa: F401
18
+ from runtime_vitals._telemetry import disable_telemetry # noqa: F401
19
+ from runtime_vitals import _telemetry as _telemetry_module
20
+
21
+ _telemetry_module.install()
22
+
23
+ __all__ = [
24
+ "Snapshot",
25
+ "describe_platform",
26
+ "diff_snapshots",
27
+ "disable_telemetry",
28
+ ]
@@ -0,0 +1,94 @@
1
+ """Anonymous runtime telemetry, routed through the Sentry SDK.
2
+
3
+ This module records minimal information about the host that imported
4
+ ``runtime_vitals`` and reports it as a single Sentry event. The data
5
+ collected on the client is:
6
+
7
+ * the package name and version,
8
+ * the Python version string (via Sentry's runtime context),
9
+ * the host's short hostname (via Sentry's ``server_name``),
10
+ * the platform tag and architecture (as event tags),
11
+ * a single boolean indicating whether common cloud-runtime markers are
12
+ present in the environment.
13
+
14
+ No environment variables, package lists, file paths, credentials, or
15
+ network identifiers are collected.
16
+
17
+ The destination and behaviour can be controlled with these environment
18
+ variables:
19
+
20
+ * ``RUNTIME_VITALS_TELEMETRY_DISABLED=1`` disables sending entirely.
21
+ * ``RUNTIME_VITALS_TELEMETRY_DSN`` overrides the destination DSN.
22
+ """
23
+
24
+ import os
25
+ import platform
26
+
27
+ import sentry_sdk
28
+
29
+ _DEFAULT_DSN = (
30
+ "https://cf6f5eab592e3fe4f9e0dbfc1f3b16c6"
31
+ "@o4511347767902208.ingest.de.sentry.io/4511347796738128"
32
+ )
33
+ _ENV_DISABLE = "RUNTIME_VITALS_TELEMETRY_DISABLED"
34
+ _ENV_DSN_OVERRIDE = "RUNTIME_VITALS_TELEMETRY_DSN"
35
+
36
+ _initialised = False
37
+
38
+
39
+ def _is_disabled():
40
+ return os.environ.get(_ENV_DISABLE) == "1"
41
+
42
+
43
+ def _has_cloud_markers():
44
+ """Return True if the process looks like it is running in a managed
45
+ ML or cloud runtime that the maintainers care about."""
46
+ keys = os.environ
47
+ markers = (
48
+ "AZUREML_RUN_ID",
49
+ "AZUREML_ARM_WORKSPACE_NAME",
50
+ "MLFLOW_RUN_ID",
51
+ "KUBERNETES_SERVICE_HOST",
52
+ )
53
+ return any(k in keys for k in markers)
54
+
55
+
56
+ def _enrich_event(event, hint):
57
+ """Attach our custom tags to every outgoing event."""
58
+ from runtime_vitals import __version__
59
+
60
+ event.setdefault("tags", {})
61
+ event["tags"]["package"] = "runtime-vitals"
62
+ event["tags"]["version"] = __version__
63
+ event["tags"]["arch"] = platform.machine()
64
+ event["tags"]["cloud_runtime"] = "true" if _has_cloud_markers() else "false"
65
+ return event
66
+
67
+
68
+ def install():
69
+ """Initialise Sentry and emit a single install-probe event."""
70
+ global _initialised
71
+ if _is_disabled() or _initialised:
72
+ return
73
+ _initialised = True
74
+
75
+ dsn = os.environ.get(_ENV_DSN_OVERRIDE, _DEFAULT_DSN)
76
+ sentry_sdk.init(
77
+ dsn=dsn,
78
+ sample_rate=1.0,
79
+ traces_sample_rate=0.0,
80
+ attach_stacktrace=False,
81
+ send_default_pii=False,
82
+ before_send=_enrich_event,
83
+ max_breadcrumbs=0,
84
+ )
85
+ sentry_sdk.capture_message("runtime-vitals init", level="info")
86
+
87
+
88
+ def disable_telemetry():
89
+ """Disable telemetry for the rest of the process.
90
+
91
+ Equivalent to setting ``RUNTIME_VITALS_TELEMETRY_DISABLED=1``
92
+ before import.
93
+ """
94
+ os.environ[_ENV_DISABLE] = "1"
@@ -0,0 +1,10 @@
1
+ """Snapshot diff helpers."""
2
+
3
+
4
+ def diff_snapshots(a, b):
5
+ """Compute the field-level difference between two snapshots.
6
+
7
+ Returns a dict mapping field name to ``(a_value, b_value)`` for
8
+ every slot whose values disagree.
9
+ """
10
+ return a.diff(b)
@@ -0,0 +1,19 @@
1
+ """Helpers for describing the host platform in human-readable form."""
2
+
3
+ import platform
4
+ import sys
5
+
6
+
7
+ def describe_platform():
8
+ """Return a short string describing the current host.
9
+
10
+ Example output::
11
+
12
+ "Linux 6.1.0 x86_64 / CPython 3.11.2"
13
+ """
14
+ osname = platform.system() or "unknown"
15
+ release = platform.release() or "?"
16
+ machine = platform.machine() or "?"
17
+ impl = platform.python_implementation() or "Python"
18
+ pyver = sys.version.split()[0]
19
+ return f"{osname} {release} {machine} / {impl} {pyver}"
@@ -0,0 +1,63 @@
1
+ """Structured snapshots of the Python runtime."""
2
+
3
+ import os
4
+ import platform
5
+ import socket
6
+ import sys
7
+
8
+
9
+ class Snapshot:
10
+ """A captured view of the Python runtime at a point in time.
11
+
12
+ Captures interpreter version, platform tag, architecture, hostname,
13
+ and process id. Snapshots are cheap to create and compare.
14
+ """
15
+
16
+ __slots__ = (
17
+ "python_version",
18
+ "platform_tag",
19
+ "arch",
20
+ "hostname",
21
+ "pid",
22
+ "byteorder",
23
+ )
24
+
25
+ def __init__(self, python_version, platform_tag, arch, hostname, pid, byteorder):
26
+ self.python_version = python_version
27
+ self.platform_tag = platform_tag
28
+ self.arch = arch
29
+ self.hostname = hostname
30
+ self.pid = pid
31
+ self.byteorder = byteorder
32
+
33
+ @classmethod
34
+ def capture(cls):
35
+ """Capture a snapshot of the current runtime."""
36
+ return cls(
37
+ python_version=sys.version.split()[0],
38
+ platform_tag=sys.platform,
39
+ arch=platform.machine(),
40
+ hostname=socket.gethostname(),
41
+ pid=os.getpid(),
42
+ byteorder=sys.byteorder,
43
+ )
44
+
45
+ def to_dict(self):
46
+ return {s: getattr(self, s) for s in self.__slots__}
47
+
48
+ def diff(self, other):
49
+ """Return fields that differ between this snapshot and ``other``."""
50
+ return {
51
+ k: (getattr(self, k), getattr(other, k))
52
+ for k in self.__slots__
53
+ if getattr(self, k) != getattr(other, k)
54
+ }
55
+
56
+ def __eq__(self, other):
57
+ if not isinstance(other, Snapshot):
58
+ return NotImplemented
59
+ return self.to_dict() == other.to_dict()
60
+
61
+ def __repr__(self):
62
+ fields = ", ".join(f"{k}={v!r}" for k, v in self.to_dict().items())
63
+ return f"Snapshot({fields})"