Metadata-Version: 2.4
Name: eigenh-observe
Version: 0.4.0
Summary: EigenH observability — structured logs + AI events + distributed traces
License: MIT License
        
        Copyright (c) 2026 EigenH
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: posthog>=3.0.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.40b0; extra == 'fastapi'
Provides-Extra: http
Requires-Dist: opentelemetry-instrumentation-aiohttp-client>=0.40b0; extra == 'http'
Requires-Dist: opentelemetry-instrumentation-httpx>=0.40b0; extra == 'http'
Requires-Dist: opentelemetry-instrumentation-requests>=0.40b0; extra == 'http'
Description-Content-Type: text/markdown

# eigenh-observe

Observability package for EigenH services — structured logs, AI generation events, and distributed traces, all routed to PostHog.

## Install

```bash
pip install eigenh-observe
```

## Quick start

```python
import eigenh_observe

eigenh_observe.init(
    service_name="my-service",
    env="prod",
    instrument_http=True,
)

token = eigenh_observe.set_call_context(call_id="room-123", org_id="org-abc", caller="+1234567890")
try:
    with eigenh_observe.session_span():
        with eigenh_observe.llm_span("gemini-2.5-flash") as span:
            # ... call your LLM ...
            span.set_usage(input_tokens=100, output_tokens=50)
finally:
    eigenh_observe.reset_call_context(token)
```

## Features

- Structured logs → PostHog Logs (with `call_id`, `org_id`, `caller` as filterable attributes)
- AI generation events → PostHog AI Observability (`$ai_generation`, `$ai_span`)
- Distributed traces → PostHog Traces (session → llm → tool span tree)
- HTTP auto-instrumentation (`requests`, `httpx`, `aiohttp`)
- FastAPI inbound `traceparent` extraction

## Environment variables

| Variable | Purpose |
|---|---|
| `POSTHOG_API_KEY` | PostHog project API key |
| `POSTHOG_HOST` | PostHog host (default: `https://us.i.posthog.com`) |
| `APP_ENV` | Environment name (`dev`, `stage`, `prod`) |

## License

MIT
