Skip to main content

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)

Metadata

Release files for ghost-doc-agent 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ghost-doc-agent 0.1.0
File Size Uploaded
ghost_doc_agent-0.1.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ghost-doc-agent 0.1.0
File Interpreter ABI Platform
ghost_doc_agent-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / ghost_doc_agent-0.1.0.tar.gz

Download URL ghost_doc_agent-0.1.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
506255bc3669edf2a447f19860259ba0235a4620f9c51bf253fabefac732bbfc
BLAKE2b-256 checksum
How to use checksums
ad33be38010af301d1ed68f8f7f74b04462b8775ea881503a3f81f098920cc61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 30, 2026.

Transparency log

Release files / ghost_doc_agent-0.1.0-py3-none-any.whl

Download URL ghost_doc_agent-0.1.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
591eba7c5ac731e1c3888b6b7c657491058d2d387d067dc26ca75b6a15f2f2da
BLAKE2b-256 checksum
How to use checksums
a6654e0773c973630b7f173930fbeb3276641c66989381bbf00d3c3402da6817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page