Skip to main content

Zespan observability middleware for Flask

Project description

zespan-flask

Automatic LLM observability middleware for Flask. Traces every request, LLM call, and custom span with zero code changes for basic usage.

Installation

pip install zespan-flask

Quick Start

from flask import Flask
from zespan_flask import ZespanFlaskExtension, ZespanConfig

app = Flask(__name__)

config = ZespanConfig(api_key="zsp_your_api_key")
lumiq = ZespanFlaskExtension(app, config)

Every HTTP request is now automatically traced.

Application Factory Pattern

lumiq = ZespanFlaskExtension()

def create_app():
    app = Flask(__name__)
    lumiq.init_app(app)
    return app

Trace LLM Calls

from zespan_flask import observe_llm

@observe_llm(model="gpt-4o", provider="openai")
def generate_response(prompt: str):
    response = openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": prompt}]
    )
    return response

Trace Custom Spans

from zespan_flask import observe_span

@observe_span("fetch_context", span_type="retrieval")
def fetch_context(query: str):
    return vector_db.search(query)

Set Custom Attributes

from zespan_flask import set_attribute

@app.route("/chat")
def chat():
    set_attribute("user.id", current_user.id)
    set_attribute("session.id", session.get("id"))

Configuration

Option Default Description
api_key required Zespan API key (zsp_...)
base_url https://api.zespan.com API endpoint
enabled True Toggle tracing on/off
sample_rate 1.0 Fraction of requests to trace (0.0–1.0)
capture_request_body False Include request body in traces
capture_response_body False Include response body in traces
redact_fields ["password","token","api_key"] Fields redacted automatically
debug False Print flush errors to stdout

Get your API key at zespan.com.

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

zespan_flask-1.0.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

zespan_flask-1.0.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file zespan_flask-1.0.0.tar.gz.

File metadata

  • Download URL: zespan_flask-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.18 30 Sep 2025","python":"3.14.2","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

File hashes

Hashes for zespan_flask-1.0.0.tar.gz
Algorithm Hash digest
SHA256 92dc2b5dca3c6a6cccb98d12626dfc7798daf982c22d94469af90bef152e4535
MD5 ce751b9cdc08f6ec7e92b5728e9ae766
BLAKE2b-256 eb5f8dcb061b880a8200be3f4a5db592d84feed9fcc3115497a21c8345b82845

See more details on using hashes here.

File details

Details for the file zespan_flask-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: zespan_flask-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.18 30 Sep 2025","python":"3.14.2","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

File hashes

Hashes for zespan_flask-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05efdfc78027783be484599d20fe1ee88ae50dfe7d229262cb0345438cf8df7c
MD5 e3390ca063ef7c44fcf383b4c9ef08ca
BLAKE2b-256 60536b368a368aaa25e3b0482e26c560e0acaaf893f5cc03bbcd472820f78cfe

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