nameko-chassis
docs |
|
|---|---|
tests |
|
package |
nameko-chassis provides an opinionated base class for building resilient, observable microservices with the nameko framework.
nameko-chassis releases and distributed tracing
We’ve changed the approach to distributed tracing over a few releases. Here’s an overview:
0.9.0 supports only nameko 2 and has Zipkin integration
1.0 supports both nameko 2 and 3 RC, while dropping Zipkin. If you need Zipkin support and your service is still on nameko 2, either stay on nameko-chassis 0.9, or upgrade to 1.x and manage nameko-zipkin yourself.
2.0 supports only nameko v3 and provides a predefined OpenTelemetry integration to base Service class. You can still use OpenTelemetry with nameko-chassis 1.0 (provided you’re using nameko 3), but before 2.0 you’ll need to set it up yourself.
Features
By using nameko_chassis.service.Service, you’ll get:
error reporting using Sentry
integrated metrics endpoint for Prometheus
helpers for service discovery
partial* support for OpenTelemetry tracing
*You’ll need to call the instrumentors yourself, but we provide basic configuration as a dependency provider.
Installation
pip install nameko-chassis
You can also install the in-development version with:
pip install https://github.com/Emplocity/nameko-chassis/archive/master.zip
Usage
Base service class
from nameko.rpc import rpc
from nameko_chassis.service import Service
class MyService(Service):
name = "my_service"
@rpc
def my_method(self):
try:
do_something()
except Exception:
self.sentry.captureException()
Distributed tracing
Since nameko-chassis 2.0, we provide an opinionated setup of OpenTelemetry. Your services will export traces over HTTP to an endpoint defined in OTEL_EXPORTER_OTLP_ENDPOINT environment variable. However, you need to call instrumentors yourself, for example:
from nameko_chassis.service import Service
from nameko_opentelemetry import NamekoInstrumentor
from opentelemetry.instrumentation.logging import LoggingInstrumentor
LoggingInstrumentor().instrument()
NamekoInstrumentor().instrument(
send_headers=True,
send_request_payloads=True,
send_response_payloads=True,
max_truncate_length=1000,
)
class MyService(Service):
name = "my_service"
Backdoor debugging
nameko-chassis.debug includes helpers for introspecting running services with nameko backdoor feature. For example if your service exposes backdoor on port 12345:
$ rlwrap nc -v localhost 12345
Connection to localhost 12345 port [tcp/*] succeeded!
Python 3.8.8 (default, Mar 23 2021, 11:02:14)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from nameko_chassis.debug import debug_runner
>>> debug_runner(runner)
╭──────────────────────────── sleeping_http_service ───────────────────────────╮
│ 19 entrypoints │
│ 15 dependencies │
│ running 1/10 worker threads │
│ ╭────────────────── Thread #0: SleepingHttpService.sleep ──────────────────╮ │
│ │ │ │
│ │ Args: ["<Request 'http://127.0.0.1:8000/sleep/500' [GET]>"] │ │
│ │ Kwargs: {'duration': '500'} │ │
│ │ Context data: {'X-B3-ParentSpanId': '1058ef878ab0fe32'} │ │
│ │ │ │
│ │ Traceback: │ │
│ │ File │ │
│ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │
│ │ line 221, in main │ │
│ │ result = function(*args, **kwargs) │ │
│ │ File │ │
│ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/nameko/c… │ │
│ │ line 392, in _run_worker │ │
│ │ result = method(*worker_ctx.args, **worker_ctx.kwargs) │ │
│ │ File "./app/service.py", line 73, in sleep │ │
│ │ time.sleep(duration) │ │
│ │ File │ │
│ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │
│ │ line 36, in sleep │ │
│ │ hub.switch() │ │
│ │ File │ │
│ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │
│ │ line 313, in switch │ │
│ │ return self.greenlet.switch() │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
Documentation
Development
To run the all tests run:
tox
License
This work is released under the Apache 2.0 license.
Metadata
Release files for nameko-chassis 3.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 | Actions |
|---|---|---|---|---|
| nameko_chassis-3.2.0.tar.gz | 9.3 kB | Without provenance | Details for nameko_chassis-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nameko_chassis-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for nameko_chassis-3.2.0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / nameko_chassis-3.2.0.tar.gz
| Download URL | nameko_chassis-3.2.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9938866e4311e33561371f0b7714ed68c7ded733cc01dfe02a8c465a7cd467f9
|
|
BLAKE2b-256 checksum How to use checksums |
fcf6e19ba62eec2ec5f2eaf466056f58230a11e119787f25a77e32dcc75027da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Release files / nameko_chassis-3.2.0-py3-none-any.whl
| Download URL | nameko_chassis-3.2.0-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb06feb56ec48a59e3fd12ec31f6c00cf795771dc9e97b1e7926abac9773ff7f
|
|
BLAKE2b-256 checksum How to use checksums |
2d2806ce5383b051a61074eedd6fb39de35b4190f9edceedfd75df7b336f0581
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Security for nameko-chassis 3.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.