Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.81 KB

File metadata and controls

72 lines (51 loc) · 1.81 KB

Quickstart

Get run-level cost attribution working in minutes.

Prerequisites

Step 1: Install

pip install "botanu[all]"

Step 2: Enable

from botanu import enable

enable(service_name="my-service")

Step 3: Define Entry Point

from botanu import botanu_use_case

@botanu_use_case(name="process_order")
def process_order(order_id: str):
    order = db.get_order(order_id)
    result = llm.analyze(order)
    return result

All LLM calls, database queries, and HTTP requests inside the function are automatically tracked with the same run_id.

Complete Example

from botanu import enable, botanu_use_case

enable(service_name="order-service")

@botanu_use_case(name="process_order")
def process_order(order_id: str):
    order = db.get_order(order_id)
    result = openai.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": order.description}]
    )
    db.save_result(order_id, result)
    return result

What Gets Tracked

Attribute Example Description
botanu.run_id 019abc12-... Unique run identifier
botanu.use_case process_order Business use case
gen_ai.usage.input_tokens 150 LLM input tokens
gen_ai.usage.output_tokens 200 LLM output tokens
db.system postgresql Database system

All spans share the same run_id, enabling cost-per-transaction analytics.

Next Steps