Request-flow reconstruction and HUMAN_API replay for Mobius Python (FastAPI) services, built on the span/parent-span action-log fields written by mobius-tracer-py and mobius-auditlog-py.
Project description
mobius-operations-trace-py
Request-flow reconstruction and HUMAN_API replay for Mobius Python (FastAPI)
services. Python port of platform-artifact-lifecycle-lib +
platform-artifact-lifecycle-web (MPH-926 / MPH-928), verified against
the Java source (OperationTraceServiceImpl, LifecycleOperationsExceptionHandler).
Relies on action-log rows carrying spanid / parentservicespanid /
requestid / httpmethod / httpurl / requesterid / actionsource, written
by mobius-tracer-py +
mobius-auditlog-py.
What it does
get_request_flow(txnid, requestid)— queries action logs (either identifier alone is enough) and rebuilds the causal call tree (HUMAN_APIentry point first, then each service hop it triggered, in call order) from thespanid/parentservicespanidfields.replay_request(txnid, requestid)— finds the originatingHUMAN_APIcall, exchanges the original requester's identity for a bearer token, and re-issues that exact HTTP call (method/URL/body).
Both are exposed as FastAPI endpoints:
GET /v1/operations/request-flows?txnid=...&requestid=...POST /v1/operations/request-replays?txnid=...&requestid=...
Error handling mirrors the Java REST layer:
- Internal failures (missing identifiers, PI lookup failure, missing
HUMAN_APIfields, replay connectivity failure) → HTTP 400 with the same envelopeLifecycleOperationsExceptionHandleremits (timestamp,origin,errorCode,errorMessage,httpStatusCode,actionsRequired). - A replayed target's own response — even a 4xx/5xx — is forwarded verbatim instead of raised, with the outer HTTP status set to match the target's.
Usage
This package has no hard dependency on a specific action-log store or IAM client — you supply small adapters:
from mobius_operations_trace import setup_operations_trace
setup_operations_trace(
app,
token_provider=my_token_provider, # TokenProvider protocol
instances_list_url="http://pi-service/v2.0/schemas/{schemaId}/instances/list",
schema_id="action-log-schema-id",
)
instances_list_url must contain a literal {schemaId} placeholder — PI
takes the schema id as a URL path variable, not a body field (matches
lifecycle.operations.trace.instances-list-url on the Java side). Pass
action_log_source instead of instances_list_url/schema_id to bypass the
built-in PI-backed source entirely.
TokenProvider has a single method, retrieve_token_from_tenant_id(tenant_id)
— used both to authenticate the PI query (with the fixed
PI_SERVICE_TENANT_ID) and to authenticate a replay as the original requester
(with the HUMAN_API row's requesterid), matching the Java side's single
IamVaultUtils.retrieveTokenFromTenantId method.
See mobius_operations_trace.pi_client.ActionLogSource and
mobius_operations_trace.tokens.TokenProvider for the full adapter contracts.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mobius_operations_trace_py-1.0.0.tar.gz.
File metadata
- Download URL: mobius_operations_trace_py-1.0.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f602835b1c1f1dabe6f6d0d60ead0ad945e5740bc9a7d08281f2374ba11455ce
|
|
| MD5 |
396bbecf8df5359e9d571fbefe6f4ce3
|
|
| BLAKE2b-256 |
34d213ccea5a95f61430c4f682a724727663e64f09c417024a2f0f43ee5f2a86
|
File details
Details for the file mobius_operations_trace_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mobius_operations_trace_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224e50134f2524b4e10d711cde9e57f2a05b7bd4d5ce38a907725f31de4bbfdd
|
|
| MD5 |
1dee6ad52fd7c58a933f7549ac5d3af8
|
|
| BLAKE2b-256 |
f29b53a43f1099bfa45c6d1763571d5b2f37a309fc15d1731061d2e986b8f2ce
|