Skip to content

Latest commit

 

History

History
99 lines (72 loc) · 2.06 KB

File metadata and controls

99 lines (72 loc) · 2.06 KB

Decorators API Reference

@botanu_use_case

The primary decorator for creating runs with automatic context propagation.

from botanu import botanu_use_case

@botanu_use_case(
    name: str,
    workflow: Optional[str] = None,
    environment: Optional[str] = None,
    tenant_id: Optional[str] = None,
)

Parameters

Parameter Type Default Description
name str Required Use case name for grouping
workflow str Function name Workflow identifier
environment str From env Deployment environment
tenant_id str None Tenant identifier for multi-tenant systems

Example

from botanu import botanu_use_case

@botanu_use_case(name="my_workflow")
def my_function():
    data = db.query(...)
    result = llm.complete(...)
    return result

Span Attributes

Attribute Description
botanu.run_id Generated UUIDv7
botanu.use_case name parameter
botanu.workflow workflow parameter or function name
botanu.environment Deployment environment
botanu.tenant_id Tenant identifier (if provided)

Alias

use_case is an alias for botanu_use_case:

from botanu import use_case

@use_case(name="my_workflow")
def my_function():
    return db.query(...)

@botanu_outcome

Decorator for sub-functions to emit outcomes based on success/failure.

from botanu import botanu_outcome

@botanu_outcome()
def extract_data():
    return fetch_from_source()
  • Emits "success" on completion
  • Emits "failed" with exception class name if exception raised
  • Does NOT create a new run

Example

from botanu import botanu_use_case, botanu_outcome

@botanu_use_case(name="my_workflow")
def my_function():
    step_one()
    step_two()

@botanu_outcome()
def step_one():
    return do_work()

@botanu_outcome()
def step_two():
    return do_more_work()

See Also