55[ ![ Python] ( https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-blue )] ( https://www.python.org/ )
66[ ![ License] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( LICENSE )
77
8- OpenTelemetry-native ** run-level cost attribution** for AI workflows.
8+ OpenTelemetry-native run-level cost attribution for AI workflows.
99
1010## Overview
1111
1212Botanu adds ** runs** on top of distributed tracing. A run represents a single business transaction that may span multiple LLM calls, database queries, and services. By correlating all operations to a stable ` run_id ` , you get accurate cost attribution without sampling artifacts.
1313
1414** Key features:**
15- - 🎯 ** Run-level attribution** — Link all costs to business outcomes
16- - 🔗 ** Cross-service correlation** — W3C Baggage propagation
17- - 📊 ** OTel-native** — Works with any OpenTelemetry-compatible backend
18- - ⚡ ** Minimal overhead** — < 0.5ms per request
19- - 🤖 ** GenAI support** — OpenAI, Anthropic, Vertex AI, and more
15+ - ** Run-level attribution** — Link all costs to business outcomes
16+ - ** Cross-service correlation** — W3C Baggage propagation
17+ - ** OTel-native** — Works with any OpenTelemetry-compatible backend
18+ - ** GenAI support** — OpenAI, Anthropic, Vertex AI, and more
2019
2120## Quick Start
2221
2322``` python
2423from botanu import enable, botanu_use_case, emit_outcome
2524
26- # Initialize at startup
2725enable(service_name = " my-app" )
2826
2927@botanu_use_case (name = " Customer Support" )
3028async def handle_ticket (ticket_id : str ):
31- # All operations inside get the same run_id
3229 context = await fetch_context(ticket_id)
3330 response = await generate_response(context)
34-
35- # Record the business outcome
3631 emit_outcome(" success" , value_type = " tickets_resolved" , value_amount = 1 )
3732 return response
3833```
3934
4035## Installation
4136
4237``` bash
43- # Core SDK (opentelemetry-api only, ~50KB)
44- pip install botanu
45-
46- # With OTel SDK + OTLP exporter (for standalone use)
47- pip install " botanu[sdk]"
48-
49- # With GenAI provider instrumentation
50- pip install " botanu[genai]"
51-
52- # Everything included
53- pip install " botanu[all]"
38+ pip install botanu # Core SDK
39+ pip install " botanu[sdk]" # With OTel SDK + OTLP exporter
40+ pip install " botanu[genai]" # With GenAI instrumentation
41+ pip install " botanu[all]" # Everything included
5442```
5543
56- ### Extras
57-
5844| Extra | Description |
5945| -------| -------------|
6046| ` sdk ` | OpenTelemetry SDK + OTLP HTTP exporter |
61- | ` instruments ` | Auto-instrumentation for HTTP, databases, etc. |
62- | ` genai ` | GenAI provider instrumentation (OpenAI, Anthropic, etc.) |
63- | ` carriers ` | Cross-service propagation helpers (Celery, Kafka) |
64- | ` all ` | All of the above |
65- | ` dev ` | Development and testing tools |
47+ | ` instruments ` | Auto-instrumentation for HTTP, databases |
48+ | ` genai ` | GenAI provider instrumentation |
49+ | ` carriers ` | Cross-service propagation (Celery, Kafka) |
50+ | ` all ` | All extras |
6651
6752## LLM Tracking
6853
69- Track LLM calls with full cost attribution:
70-
7154``` python
7255from botanu.tracking.llm import track_llm_call
7356
@@ -84,51 +67,20 @@ with track_llm_call(provider="openai", model="gpt-4") as tracker:
8467
8568## Data Tracking
8669
87- Track database and storage operations:
88-
8970``` python
9071from botanu.tracking.data import track_db_operation, track_storage_operation
9172
92- # Database
9373with track_db_operation(system = " postgresql" , operation = " SELECT" ) as db:
9474 result = await cursor.execute(query)
9575 db.set_result(rows_returned = len (result))
9676
97- # Storage
9877with track_storage_operation(system = " s3" , operation = " PUT" ) as storage:
9978 await s3.put_object(Bucket = " bucket" , Key = " key" , Body = data)
10079 storage.set_result(bytes_written = len (data))
10180```
10281
103- ## Architecture
104-
105- ```
106- ┌──────────────────────────────────────────────────────────────┐
107- │ Your Application │
108- │ │
109- │ @botanu_use_case track_llm_call() track_db_operation()│
110- │ │ │ │ │
111- │ └───────────────────┴────────────────────┘ │
112- │ │ │
113- │ Botanu SDK (thin) │
114- │ - Generate run_id (UUIDv7) │
115- │ - Set W3C Baggage │
116- │ - Record spans │
117- └─────────────────────────────┬─────────────────────────────────┘
118- │ OTLP
119- ▼
120- ┌──────────────────────────────────────────────────────────────┐
121- │ OpenTelemetry Collector │
122- │ │
123- │ - PII redaction - Cost calculation │
124- │ - Vendor normalization - Cardinality management │
125- └──────────────────────────────────────────────────────────────┘
126- ```
127-
12882## Documentation
12983
130- Full documentation is available at [ docs.botanu.ai] ( https://docs.botanu.ai ) and in the [ ` docs/ ` ] ( ./docs/ ) folder:
131-
13284- [ Getting Started] ( ./docs/getting-started/ )
13385- [ Concepts] ( ./docs/concepts/ )
13486- [ Tracking Guides] ( ./docs/tracking/ )
@@ -138,18 +90,18 @@ Full documentation is available at [docs.botanu.ai](https://docs.botanu.ai) and
13890## Requirements
13991
14092- Python 3.9+
141- - OpenTelemetry Collector (for production use )
93+ - OpenTelemetry Collector (recommended for production)
14294
14395## Contributing
14496
145- See [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) . This project uses [ DCO] ( ./DCO ) sign-off.
97+ See [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) . This project uses DCO sign-off.
14698
14799``` bash
148100git commit -s -m " Your commit message"
149101```
150102
151103## License
152104
153- [ Apache-2.0] ( ./LICENSE ) — see [ NOTICE ] ( ./NOTICE ) for attribution.
105+ [ Apache-2.0] ( ./LICENSE )
154106
155107This project is an [ LF AI & Data Foundation] ( https://lfaidata.foundation/ ) project.
0 commit comments