periskop-python
Periskop requires collecting and aggregating exceptions on the client side, as well as exposing them via an HTTP endpoint using a well defined format.
This library provides low level collection and rendering capabilities
Install
pip install periskop-client
Usage example
import json
from http.server import HTTPServer
from periskop_client.collector import ExceptionCollector
from periskop_client.exporter import ExceptionExporter
from periskop_client.handler import exception_http_handler
from periskop_client.models import HTTPContext
def faulty_json():
return json.loads('{"id":')
if __name__ == "__main__":
collector = ExceptionCollector()
try:
faulty_json()
except Exception as exception:
# Report without context
collector.report(exception)
# Report with HTTP context without request body
collector.report_with_context(
exception,
HTTPContext("GET", "http://example.com", {"Cache-Control": "no-cache"}),
)
# Report with HTTP context with request body
collector.report_with_context(
exception,
HTTPContext("GET", "http://example.com", {"Cache-Control": "no-cache"}, "request_body"),
)
# Expose collected exceptions in localhost:8081/-/exceptions
server_address = ("", 8081)
handler = exception_http_handler(
path="/-/exceptions", exporter=ExceptionExporter(collector)
)
http_server = HTTPServer(server_address, handler)
http_server.serve_forever()
Using push gateway
You can also use pushgateway in case you want to push your metrics
instead of using pull method. Use only in case you really need it (e.g a batch job) as it would degrade the performance
of your application. In the following example, we assume that we deployed an instance of periskop-pushgateway
on http://localhost:6767:
exporter = ExceptionExporter(collector)
exporter.push_to_gateway("http://localhost:6767")
Run tests
For running tests pytest is needed. A recommended way to run all check is installing tox and then just type tox. This will run pytest tests, black formatter and flake8 and mypy static code analyzers.
Alternatively you can run pip install -r requirements-tests.txt and then run pytest.
Metadata
Release files for periskop-client 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| periskop-client-0.2.0.tar.gz | 8.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| periskop_client-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / periskop-client-0.2.0.tar.gz
| Download URL | periskop-client-0.2.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a48a759ba571dcf8623451d5ffbf41867c08a5910682ff37d4b41917859e4f28
|
|
BLAKE2b-256 checksum How to use checksums |
7c2e806047fe83d9eee429d1a31a0c45e383244ad0990149daa27dabeee8b0cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.10 Linux/5.4.0-88-generic
|
Release files / periskop_client-0.2.0-py3-none-any.whl
| Download URL | periskop_client-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ea552195260d9ea9ff00719161e8e3a353879e601aa03a7fd2b906a73ac19bc
|
|
BLAKE2b-256 checksum How to use checksums |
6b02e278dfa1a151609708d187aa981f5e1ad067a3dfd05a3ac6d292201b6844
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.10 Linux/5.4.0-88-generic
|
Security for periskop-client 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.