Metadata-Version: 2.4
Name: obskitpy
Version: 0.11.1
Summary: Observability (OpenTelemetry + Elasticsearch + Kibana) for any Python project, through a CLI.
Author: Pedro França
License-Expression: MIT
Project-URL: Homepage, https://github.com/pedrowill-dev/obskitpy
Project-URL: Documentation, https://github.com/pedrowill-dev/obskitpy/tree/main/docs
Project-URL: Issues, https://github.com/pedrowill-dev/obskitpy/issues
Keywords: observability,opentelemetry,elasticsearch,kibana,rpa,logging,tracing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Logging
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: opentelemetry-api==1.27.0
Requires-Dist: opentelemetry-sdk==1.27.0
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc==1.27.0
Provides-Extra: requests
Requires-Dist: opentelemetry-instrumentation-requests==0.48b0; extra == "requests"
Requires-Dist: setuptools==75.6.0; extra == "requests"
Provides-Extra: portal
Requires-Dist: fastapi<0.150,>=0.115; extra == "portal"
Requires-Dist: uvicorn>=0.30; extra == "portal"
Requires-Dist: sqlalchemy>=2.0; extra == "portal"
Requires-Dist: psycopg[binary]>=3.2; extra == "portal"
Requires-Dist: cryptography>=43; extra == "portal"
Requires-Dist: httpx>=0.27; extra == "portal"
Requires-Dist: pydantic>=2.8; extra == "portal"
Requires-Dist: websockets>=12; extra == "portal"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

<p align="center"><img src="https://raw.githubusercontent.com/pedrowill-dev/obskitpy/main/docs/images/logo.png" alt="obskitpy" width="380"></p>

# obskitpy

Observability (OpenTelemetry → Elasticsearch → Kibana) for any Python project, through a CLI.

> Full documentation at the repository root: [`docs/`](https://github.com/pedrowill-dev/obskitpy/blob/main/docs/quick-start.md) (English, with a Portuguese copy in `docs/pt-BR/`). This file is a summary.
> The CLI messages and dashboards are currently in Brazilian Portuguese.

## Getting started (2 commands)

```bash
uv add "obskitpy[requests]"      # or pip install; the 'requests' extra adds automatic HTTP spans
cd my-project
obskitpy init                   # creates observability/ (stack + base dashboard); optional --service NAME
obskitpy up                     # starts ES + Kibana + Collector and creates the dashboard
```

In your code:

```python
import logging, obskitpy

log = logging.getLogger(__name__)
shutdown = obskitpy.setup("my-service")      # logs + traces + metrics over OTLP (localhost:4317)

@obskitpy.traced()                            # one span per call, marks an error if the exception propagates
def process(item): ...

try:
    process(x)
except Exception:
    log.exception("failed")                 # comes out with error.type, error.origin and error.chain

shutdown()                                  # flushes pending data
```

Custom metrics: `obskitpy.meter().create_counter("orders.processed")` (OpenTelemetry API).

## Commands

| Command | What it does |
|---|---|
| `obskitpy init [--service N] [--kibana-port P ...]` | creates `observability/` (compose, collector, `dashboard.ndjson`, `.env`) |
| `obskitpy up` | starts the stack, waits until it is healthy and **applies the dashboard** |
| `obskitpy down [-v]` | brings it down (`-v` deletes the data) |
| `obskitpy status` / `obskitpy open` | containers + link / opens the dashboard |
| `obskitpy dashboard export` | writes the dashboard **as it is in Kibana** to the file |
| `obskitpy dashboard apply` | imports `observability/dashboard.ndjson` into Kibana |

All of them accept `--dir` (default `observability`).

## Evolving the dashboard

1. `obskitpy up` already creates the `<service>-observability` dashboard with the basic panels: logs, errors, runs (traces), span duration, errors by type/origin and an error list with `trace_id`.
2. Edit it in Kibana (add panels, metrics from your domain, filters).
3. `obskitpy dashboard export` and version `observability/dashboard.ndjson` in git.
4. On another machine/CI: `obskitpy up` (or `obskitpy dashboard apply`) recreates everything.

The panels filter by `resource.attributes.service.name`, so several services can share one stack (use the same `--dir`/ports) or have one each (use different ports in `init`).

## Notes

- Local environment: Elasticsearch security off, ports on `127.0.0.1` only.
- The data takes a few seconds to become searchable after the first send.
- Colima/Docker: `docker compose` must be able to see the project folder (on Colima, only `$HOME` is mounted by default).
- Requires Docker with the Compose v2 plugin.
