Skip to main content

Which Pattern?


Serverless

Why: In serverless, the first request (“cold start”) initializes everything from scratch. Subsequent requests (“warm starts”) reuse the same container. Lazy initialization takes advantage of this - initialize the tracer once, reuse it across warm requests.
Alternative: LRU cache achieves the same lazy initialization:

Server

Why: Web servers handle many concurrent requests. Initialize the tracer once when the app starts, then create a new session per request using create_session() (sync) or acreate_session() (async) so each request gets isolated traces.
For multi-turn conversations, custom session IDs, and scoped sessions, see Tracer Initialization.

FastAPI

Flask


Error Handling

Tracing should never crash your app. Handle missing config gracefully:

Environment Configuration

The Python SDK can be configured entirely through environment variables, which is the recommended approach for containerized and CI/CD deployments.
See the full Environment Variables Reference for all available variables, defaults, and aliases.

Kubernetes


Checklist

Before deploying:
  1. HH_API_KEY environment variable set (API keys are project-scoped)
  2. ✅ Tested with HH_API_KEY="" to verify graceful degradation
  3. ✅ Traces appearing in HoneyHive dashboard

What’s Next?

Tracer Initialization Patterns

Multi-turn sessions, scoped sessions, and patterns for serverless, web servers, and experiments

Trace Distributed Systems

Trace requests across service boundaries with context propagation
Questions? Join our Discord community or email support@honeyhive.ai