Metadata-Version: 2.5
Name: servicedna
Version: 0.2.0
Summary: Connect a Python service to ServiceDNA: traces, self-registration and health heartbeats with two environment variables.
Project-URL: Source, https://github.com/varuns2903/servicedna/tree/main/sdks/python
License-Expression: MIT
Requires-Python: >=3.9
Requires-Dist: opentelemetry-api~=1.45
Requires-Dist: opentelemetry-exporter-otlp-proto-http~=1.45
Requires-Dist: opentelemetry-instrumentation-aiohttp-client==0.66b0
Requires-Dist: opentelemetry-instrumentation-asgi==0.66b0
Requires-Dist: opentelemetry-instrumentation-confluent-kafka==0.66b0
Requires-Dist: opentelemetry-instrumentation-django==0.66b0
Requires-Dist: opentelemetry-instrumentation-fastapi==0.66b0
Requires-Dist: opentelemetry-instrumentation-flask==0.66b0
Requires-Dist: opentelemetry-instrumentation-grpc==0.66b0
Requires-Dist: opentelemetry-instrumentation-httpx==0.66b0
Requires-Dist: opentelemetry-instrumentation-kafka-python==0.66b0
Requires-Dist: opentelemetry-instrumentation-psycopg2==0.66b0
Requires-Dist: opentelemetry-instrumentation-redis==0.66b0
Requires-Dist: opentelemetry-instrumentation-requests==0.66b0
Requires-Dist: opentelemetry-instrumentation-sqlalchemy==0.66b0
Requires-Dist: opentelemetry-instrumentation-urllib3==0.66b0
Requires-Dist: opentelemetry-instrumentation-wsgi==0.66b0
Requires-Dist: opentelemetry-instrumentation==0.66b0
Requires-Dist: opentelemetry-sdk~=1.45
Provides-Extra: test
Requires-Dist: fastapi; extra == 'test'
Requires-Dist: grpcio; extra == 'test'
Requires-Dist: grpcio-health-checking; extra == 'test'
Requires-Dist: httpx; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-asyncio; extra == 'test'
Requires-Dist: uvicorn; extra == 'test'
Description-Content-Type: text/markdown

# servicedna (Python)

Connect a Python service to [ServiceDNA](https://github.com/varuns2903/servicedna) with one
dependency and two environment variables. You get:

- **Distributed traces** for FastAPI, Flask, Django, ASGI/WSGI, requests, httpx, urllib3,
  aiohttp, gRPC, SQLAlchemy, psycopg2, Redis and Kafka (OpenTelemetry auto-instrumentation —
  only libraries you actually use are instrumented)
- **Self-registration** — the service appears in ServiceDNA on first start
- **Health heartbeats** — the service's own `/health` is checked and reported every 15 s

## Install

```bash
pip install servicedna
```

## Run

Prefix your usual command with `servicedna-run`:

```bash
SERVICEDNA_URL=https://servicedna.example.com \
SERVICEDNA_KEY=sdna_ik_... \
servicedna-run uvicorn app.main:app --host 0.0.0.0 --port 8000
```

Or start it from code, first thing in your entry point:

```python
import servicedna
servicedna.start()
```

`servicedna-run` is preferred: it instruments libraries before your code imports them. Without
`SERVICEDNA_URL` and `SERVICEDNA_KEY` both do nothing, so the same build runs anywhere.

## Configuration

| Variable | Default | |
|---|---|---|
| `SERVICEDNA_URL` | — | ServiceDNA base URL (required) |
| `SERVICEDNA_KEY` | — | Organization ingestion key, from Settings → Integrations (required) |
| `SERVICEDNA_ENV` | — | Environment (`dev`, `staging`, `prod`…); each is tracked separately |
| `OTEL_SERVICE_NAME` / `SERVICEDNA_SERVICE` | working directory name | Service name |
| `SERVICEDNA_VERSION` | — | |
| `SERVICEDNA_HEALTH_URL` | — | Health URL **ServiceDNA** can reach, so it can also probe the service itself |
| `SERVICEDNA_HEALTH_PATH` | `/health` | Path the heartbeat checks on `http://127.0.0.1:$PORT` |
| `SERVICEDNA_LOCAL_HEALTH_URL` | from `PORT` + path | Full URL the heartbeat checks, if not on `PORT` |
| `SERVICEDNA_HEARTBEAT_MS` | `15000` | `0` disables heartbeats |
| `SERVICEDNA_DEGRADED_MS` | `2000` | Health response slower than this is reported DEGRADED |

Standard `OTEL_*` variables still apply and win over these defaults.
