Ghost Doc black-box tracing agent for Python
Project description
ghost-doc-agent (Python)
Python tracing agent for Ghost Doc.
Installation
pip install ghost-doc-agent
Quick start
from ghost_doc_agent import Tracer
tracer = Tracer(agent_id="my-python-app")
@tracer.trace
def get_user(user_id: int) -> dict:
"""Fetches a full user record from the database."""
return db.query("SELECT * FROM users WHERE id = ?", user_id)
# Async functions work too
@tracer.trace
async def fetch_data(url: str) -> bytes:
"""Downloads raw bytes from the given URL."""
...
Start the Ghost Doc Hub before running your application:
npx ghost-doc start
# → Hub + Dashboard at http://localhost:3001
Docstring auto-extraction
The agent automatically uses the first line of a function's docstring as its description in the dashboard tooltip and inspector panel. No extra configuration needed — just write normal Python docstrings.
@tracer.trace
def validate_order(order_id: str) -> bool:
"""Checks stock availability and payment validity for an order.
Args:
order_id: The UUID of the order to validate.
Returns:
True if the order can be fulfilled.
"""
...
# → Dashboard shows: "Checks stock availability and payment validity for an order."
To override the docstring or provide a description when there is none, pass description= explicitly:
@tracer.trace(description="Custom description that overrides the docstring")
def my_function(): ...
Decorator API
# No parentheses — docstring auto-extracted as description
@tracer.trace
def get_user(user_id: int): ...
# Custom label (overrides __qualname__ in the dashboard node name)
@tracer.trace(label="user.lookup")
def get_user(user_id: int): ...
# Explicit description (overrides docstring)
@tracer.trace(description="Fetches a user from the primary database replica")
def get_user(user_id: int): ...
# Label + description
@tracer.trace(label="user.lookup", description="Fetches a user from the primary database replica")
def get_user(user_id: int): ...
# Async functions — identical API
@tracer.trace
async def send_email(to: str, subject: str):
"""Sends a confirmation email via the SMTP relay."""
...
Configuration
from ghost_doc_agent import Tracer
tracer = Tracer(
agent_id="api-service", # shown in the dashboard as the agent badge
hub_url="ws://localhost:3001/agent", # default
sanitize=frozenset({"password", "token", "secret", "api_key"}),
buffer_size=500, # max spans buffered when Hub is unreachable
enabled=True, # False disables all tracing (decorators become no-ops)
)
Sanitization
Sensitive fields are redacted before leaving your process. The default blocklist covers password, token, secret, authorization, and api_key.
tracer = Tracer(
agent_id="api",
sanitize=frozenset({"password", "token", "ssn", "credit_card", "api_key"}),
)
Lifecycle
# Gracefully stop the WebSocket transport
tracer.stop()
Requirements
- Python 3.10+
websockets(installed automatically)
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 ghost_doc_agent-0.1.0.tar.gz.
File metadata
- Download URL: ghost_doc_agent-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
506255bc3669edf2a447f19860259ba0235a4620f9c51bf253fabefac732bbfc
|
|
| MD5 |
d31f8bd5ef1e376eb1258f686d74c37f
|
|
| BLAKE2b-256 |
ad33be38010af301d1ed68f8f7f74b04462b8775ea881503a3f81f098920cc61
|
Provenance
The following attestation bundles were made for ghost_doc_agent-0.1.0.tar.gz:
Publisher:
publish-python.yml on jeffev/ghost-doc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghost_doc_agent-0.1.0.tar.gz -
Subject digest:
506255bc3669edf2a447f19860259ba0235a4620f9c51bf253fabefac732bbfc - Sigstore transparency entry: 1200743799
- Sigstore integration time:
-
Permalink:
jeffev/ghost-doc@d360771cf0f8d67f7dd176cfd893bb62aad55a87 -
Branch / Tag:
refs/tags/ghost-doc-agent@0.1.0 - Owner: https://github.com/jeffev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@d360771cf0f8d67f7dd176cfd893bb62aad55a87 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ghost_doc_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ghost_doc_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
591eba7c5ac731e1c3888b6b7c657491058d2d387d067dc26ca75b6a15f2f2da
|
|
| MD5 |
67d1d202d0c2a139f3fd66695c590148
|
|
| BLAKE2b-256 |
a6654e0773c973630b7f173930fbeb3276641c66989381bbf00d3c3402da6817
|
Provenance
The following attestation bundles were made for ghost_doc_agent-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yml on jeffev/ghost-doc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghost_doc_agent-0.1.0-py3-none-any.whl -
Subject digest:
591eba7c5ac731e1c3888b6b7c657491058d2d387d067dc26ca75b6a15f2f2da - Sigstore transparency entry: 1200744420
- Sigstore integration time:
-
Permalink:
jeffev/ghost-doc@d360771cf0f8d67f7dd176cfd893bb62aad55a87 -
Branch / Tag:
refs/tags/ghost-doc-agent@0.1.0 - Owner: https://github.com/jeffev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@d360771cf0f8d67f7dd176cfd893bb62aad55a87 -
Trigger Event:
push
-
Statement type: