Metadata-Version: 2.4
Name: palqee-prisma-otel
Version: 0.6.0
Summary: Prisma OpenTelemetry SDK - Lightweight wrapper for LLM/ML system tracing
Author-email: Hartley Jean-Aime <hartley@palqee.com>
License-Expression: MIT
Requires-Python: >=3.10
Requires-Dist: opentelemetry-api>=1.21.0
Requires-Dist: opentelemetry-exporter-otlp>=1.21.0
Requires-Dist: opentelemetry-instrumentation>=0.42b0
Requires-Dist: opentelemetry-sdk>=1.21.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: anthropic
Requires-Dist: opentelemetry-instrumentation-anthropic<0.54,>=0.53.0; extra == 'anthropic'
Provides-Extra: bedrock
Requires-Dist: opentelemetry-instrumentation-bedrock<0.54,>=0.53.0; extra == 'bedrock'
Provides-Extra: dev
Requires-Dist: anthropic>=0.39.0; extra == 'dev'
Requires-Dist: boto3>=1.34.0; extra == 'dev'
Requires-Dist: botocore>=1.34.0; extra == 'dev'
Requires-Dist: commitizen>=3.10.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: opentelemetry-instrumentation-anthropic<0.54,>=0.53.0; extra == 'dev'
Requires-Dist: opentelemetry-instrumentation-bedrock<0.54,>=0.53.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# palqee-prisma-otel

A lightweight wrapper around OpenTelemetry primitives for LLM/ML system tracing. This package provides simplified configuration and integration with Prisma's authenticated OTLP Receiver.

## Installation

```bash
pip install palqee-prisma-otel
```

Imports as `palqee_prisma_otel`:

```python
from palqee_prisma_otel import configure_tracing
```

## Quick Start

```python
from palqee_prisma_otel import configure_tracing

# Initialize tracing with your Prisma API key
configure_tracing(api_key="your-api-key")

# With run and project context for trace routing
configure_tracing(
    api_key="your-api-key",
    service_name="my-service",
    run_id="run-abc123",
    project_id="proj-xyz789",
)
```

## Configuration

The package can be configured using environment variables or directly through `configure_tracing()`:

### Environment Variables

- `PALQEE_PRISMA_OTEL_ENDPOINT`: OTLP Receiver endpoint (default: `https://otel.prisma.ai:4318`)
- `PALQEE_PRISMA_API_KEY`: Your Prisma API key for authentication

### Direct Configuration

```python
from palqee_prisma_otel import configure_tracing

configure_tracing(
    api_key="your-api-key",
    endpoint="https://otel.prisma.ai:4318",  # optional, overrides env var and default
    service_name="my-service",               # optional, defaults to "prisma-app"
    run_id="run-abc123",                     # optional, attached as prisma.run.id resource attribute
    project_id="proj-xyz789",               # optional, attached as prisma.project.id resource attribute
)
```

### Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `api_key` | `str` | required | Prisma API key sent as `x-api-key` header |
| `endpoint` | `str \| None` | `None` | OTLP Receiver endpoint. Falls back to `PALQEE_PRISMA_OTEL_ENDPOINT` env var, then `https://otel.prisma.ai:4318` |
| `service_name` | `str` | `"prisma-app"` | OTEL `service.name` resource attribute |
| `run_id` | `str \| None` | `None` | Attached as `prisma.run.id` for trace-to-run routing in the Ingestor |
| `project_id` | `str \| None` | `None` | Attached as `prisma.project.id` for trace-to-project routing in the Ingestor |

## Features

- Authenticates with the Prisma OTLP Receiver via `x-api-key` header
- HTTP OTLP export with batch span processing
- Resource attributes for run and project routing
- Environment variable-based endpoint configuration

## Development

1. Clone the repository
2. Install development dependencies:
```bash
pip install -e ".[dev]"
```
3. Run tests:
```bash
pytest
```

## License

MIT License
