Skip to main content

Observability for AI agents — trace agents, tools, MCP and LLM calls with token usage, cost and latency

Project description

NightGaze

Observability for AI agents. Trace your agents, tools, MCP and LLM calls with two lines of code — and see every step, token, and millisecond of your agent workflows.

Installation

pip install nightgaze

Quick start

import nightgaze

nightgaze.init(
    api_key="al_live_...",               # from your NightGaze project settings
    base_url="https://your-nightgaze-host.com",
)

@nightgaze.agent("planner")
def plan_trip(query: str) -> str:
    hotels = search_hotels(query)
    return summarize(hotels)

@nightgaze.tool("search_hotels")
def search_hotels(query: str) -> list:
    ...

That's it. The outermost call becomes a trace; everything inside it — nested functions, LLM calls, tool calls — becomes a child span with timing, token usage, and error capture. Works with sync, async, and generator functions.

Trace your LLM calls automatically

nightgaze.instrument_openai()      # Chat Completions + Responses API
nightgaze.instrument_anthropic()   # Messages API
nightgaze.instrument_gemini()      # Google Gemini (google-genai)

Every request is captured with model, token usage, latency, and time-to-first-token for streaming — no changes to your calling code.

Framework integrations

nightgaze.instrument_langchain()    # chains, LLMs, tools, retrievers
nightgaze.instrument_langgraph()    # graphs with named node spans
nightgaze.instrument_llamaindex()   # queries, retrieval, synthesis

Decorators and manual spans

@nightgaze.agent("researcher")      # agent step
@nightgaze.tool("web_search")       # tool call
@nightgaze.trace("checkout")        # explicit workflow root
@nightgaze.mcp("fetch_docs")        # MCP tool call
@nightgaze.span                     # generic span

# or as a context manager, with custom attributes:
with nightgaze.span_context("rerank", kind="tool") as span:
    results = rerank(docs)
    span.add_metadata(doc_count=len(results))

Attribute traces to your users

nightgaze.identify(user_id="u_123", session_id="sess_9", customer_id="acme")

Every event emitted afterwards carries these identifiers, so you can filter traces by user, follow a session end-to-end, and break down cost per customer.

Streaming support

Streamed LLM responses are traced correctly: the span stays open until the stream is consumed (full generation latency) and records time_to_first_token_ms.

Safe by design

  • Never breaks your app — after init(), telemetry is best-effort; any failure means a dropped event, never an exception in your code.
  • Off the hot path — events batch in the background with compression, retries, and a circuit breaker. Fork-safe under gunicorn/celery.

Optional extras

pip install "nightgaze[openai]"       # openai
pip install "nightgaze[anthropic]"    # anthropic
pip install "nightgaze[gemini]"       # google-genai
pip install "nightgaze[langchain]"    # langchain-core
pip install "nightgaze[langgraph]"    # langgraph
pip install "nightgaze[llamaindex]"   # llama-index-core

Requirements

Python 3.9+

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nightgaze-0.1.0.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nightgaze-0.1.0-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file nightgaze-0.1.0.tar.gz.

File metadata

  • Download URL: nightgaze-0.1.0.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nightgaze-0.1.0.tar.gz
Algorithm Hash digest
SHA256 08cd3ad84d3861abe9e0afe2a2ce7312720b13556d5d46c4bb52d9dd065cb511
MD5 3e74cd1738df0d97450933059d9c3374
BLAKE2b-256 0e8a29c53c817089646709715ad9837bc0504e7f2ac2be090064c3bc486a73ae

See more details on using hashes here.

File details

Details for the file nightgaze-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nightgaze-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nightgaze-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 894d514cbc525c3f123299b97526c5bb8fe447b627149e8a4b7665db68d3d654
MD5 c642e7029150f2d2f7a6fdf0276f4874
BLAKE2b-256 15dea3c4953fd7a890b1da3ba2427d5a9b15a2bab0b557a3fca62e506144f33d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page