Skip to main content

Two-line LLM tracing for Verica: init(token) and your OpenAI/Anthropic calls land as evaluable traces.

Project description

verica-observability

Two-line LLM tracing for Verica: your OpenAI/Anthropic calls land as evaluable traces.

Install

pip install verica-observability

Use

import verica

verica.init(token=os.environ["VERICA_TOKEN"])

# Import the clients AFTER init so they are patched. OpenAI, Anthropic, and
# Gemini (the google-genai SDK) are all auto-traced, no extra code.
from openai import OpenAI
from anthropic import Anthropic
from google import genai

Sessions (multi-turn)

Traces sharing a conversation id reassemble into a Verica session. In a server handling many conversations, scope the id per request:

with verica.conversation(f"chat-{chat_id}"):
    response = client.chat.completions.create(...)

Context-local (async- and thread-safe); it overrides the global conversation_id from init(), and verica.conversation(None) suppresses the attribute for the block. For a single-conversation script, passing conversation_id="..." to init() is enough.

Resend history exactly as sent. Turns are stored as deltas: at ingest, Verica matches the history you resend against what previous turns already stored, and that match is exact (byte-identical text). If your app mutates prior messages between requests (for example, appending "Respond in JSON" to the last user message and stripping it from earlier turns when rebuilding the history), no prefix ever matches and every turn falls back to storing, and showing, the full conversation again. Keep injected instructions in the system prompt, or resend them exactly as originally sent.

Tags

Tags land on each trace (traces.tags): filter the workbench by them, and bind criteria to them so evaluation preselects the right criteria per tag.

verica.init(token=..., tags=["routina", "prod"])   # global, every trace

with verica.tags(["chat", "premium"]):              # adds to the globals
    client.chat.completions.create(...)

Per-request tags UNION with the globals (dedup, order preserved); nested scopes accumulate. Context-local, async- and thread-safe. Values are coerced with str(); the server caps at 20 tags x 120 chars.

Serverless

Call verica.flush() (or verica.shutdown()) before the runtime freezes so the span batch is exported.

Options

Option / env var Default Notes
token / VERICA_TOKEN (required) ingest-scoped API token
capture_content / VERICA_CAPTURE_CONTENT true send prompt/response content
conversation_id (none) global gen_ai.conversation.id; per-request: verica.conversation(id)
tags (none) global tags; per-request: verica.tags([...])
service_name / OTEL_SERVICE_NAME app resource service.name
debug / VERICA_DEBUG false log export errors

Fail-open by design: if Verica is unreachable or the token is invalid, spans are dropped and your app is never affected. Export errors are silent unless debug is on.

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

verica_observability-0.1.6.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

verica_observability-0.1.6-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file verica_observability-0.1.6.tar.gz.

File metadata

  • Download URL: verica_observability-0.1.6.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for verica_observability-0.1.6.tar.gz
Algorithm Hash digest
SHA256 48d2c1fdb2ae4885f45a2dabf2b3313e2e85a240a717a77744a1cc3bcc5c9318
MD5 e82df41f3f7b4eeb7a79854b83774a7e
BLAKE2b-256 c2c1605505d9d73c5cc37f64aebd9c7d85a725080c8b23e7a6a7e79cb7fd330f

See more details on using hashes here.

File details

Details for the file verica_observability-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for verica_observability-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 783bf76612c0a7a802b21a8173e0b86ef68e6bd4ad788448fdb7e2b07e85731f
MD5 85bef5fa3f40040a342ded48c464fe36
BLAKE2b-256 fdfdd57bd9d9399b4da3951b6d537871c64c4ee058fc8e5ecbe672972c8647dd

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