Skip to content

Commit 41f0774

Browse files
Merge pull request #6 from botanu-ai/developer
Developer-->Main
2 parents 0fb2a8d + 7837350 commit 41f0774

33 files changed

+4456
-2
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Initial open-source release
13+
- `enable()` / `disable()` bootstrap
14+
- `@botanu_use_case` decorator with UUIDv7 run_id
15+
- `emit_outcome()` and `set_business_context()` span helpers
16+
- `RunContextEnricher` span processor
17+
- LLM tracking with OTel GenAI semconv alignment
18+
- Data tracking for database, storage, and messaging
19+
- Resource detection for K8s, AWS, GCP, Azure, serverless
20+
- Auto-instrumentation for 20+ libraries
21+
- Optional extras: `[sdk]`, `[instruments]`, `[genai]`, `[carriers]`, `[all]`
22+
23+
[Unreleased]: https://github.com/botanu-ai/botanu-sdk-python/compare/v0.0.0...HEAD

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Botanu Code of Conduct
2+
3+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers agree to abide by the Code of Conduct available at https://lfprojects.org/policies/code-of-conduct/

MAINTAINERS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#MAINTAINERS Following is the current list of maintainers on this project
2+
3+
The maintainers are listed in alphabetical order.
4+
5+
[@deborahjacob-botanu] https://github.com/deborahjacob-botanu (Deborah Jacob)

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Botanu SDK for Python
2+
3+
[![CI](https://github.com/botanu-ai/botanu-sdk-python/actions/workflows/ci.yml/badge.svg)](https://github.com/botanu-ai/botanu-sdk-python/actions/workflows/ci.yml)
4+
[![PyPI version](https://badge.fury.io/py/botanu.svg)](https://pypi.org/project/botanu/)
5+
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/botanu-ai/botanu-sdk-python/badge)](https://scorecard.dev/viewer/?uri=github.com/botanu-ai/botanu-sdk-python)
6+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
7+
8+
OpenTelemetry-native **run-level cost attribution** for AI workflows.
9+
10+
## Overview
11+
12+
Botanu adds **runs** on top of distributed tracing. A run represents a single business execution that may span multiple traces, retries, and services. By correlating all spans to a stable `run_id`, you get accurate cost attribution without sampling artifacts.
13+
14+
## Quick Start
15+
16+
```python
17+
from botanu import enable, botanu_use_case, emit_outcome
18+
19+
enable(service_name="my-app")
20+
21+
@botanu_use_case(name="Customer Support")
22+
async def handle_ticket(ticket_id: str):
23+
result = await process_ticket(ticket_id)
24+
emit_outcome("success", value_type="tickets_resolved", value_amount=1)
25+
return result
26+
```
27+
28+
## Installation
29+
30+
```bash
31+
pip install botanu # Core (opentelemetry-api only)
32+
pip install botanu[sdk] # + OTel SDK + OTLP exporter
33+
pip install botanu[all] # Everything including GenAI instrumentation
34+
```
35+
36+
## Documentation
37+
38+
Full documentation is available at [docs.botanu.ai](https://docs.botanu.ai) and in the [`docs/`](./docs/) folder.
39+
40+
## Contributing
41+
42+
See [CONTRIBUTING.md](./CONTRIBUTING.md). This project uses [DCO](./DCO) sign-off.
43+
44+
## License
45+
46+
[Apache-2.0](./LICENSE) — see [NOTICE](./NOTICE) for attribution.

SECURITY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Please upgrade to latest stable version of Botanu which will have know security issues addressed.
6+
7+
## Reporting a Vulnerability
8+
9+
Please report security vulnerabilities privately to the Botanu [maintainer team] (https://github.com/monocle2ai/monocle/blob/main/MAINTAINER.md). Please do not post security vulnerabilities to the public issue tracker.

pyproject.toml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,25 @@ instruments = [
7272
"opentelemetry-instrumentation >= 0.41b0",
7373
"opentelemetry-instrumentation-fastapi >= 0.41b0",
7474
"opentelemetry-instrumentation-requests >= 0.41b0",
75+
"opentelemetry-instrumentation-httpx >= 0.41b0",
7576
"opentelemetry-instrumentation-flask >= 0.41b0",
77+
"opentelemetry-instrumentation-django >= 0.41b0",
7678
"opentelemetry-instrumentation-urllib3 >= 0.41b0",
79+
"opentelemetry-instrumentation-starlette >= 0.41b0",
80+
"opentelemetry-instrumentation-sqlalchemy >= 0.41b0",
81+
"opentelemetry-instrumentation-redis >= 0.41b0",
82+
"opentelemetry-instrumentation-celery >= 0.41b0",
83+
"opentelemetry-instrumentation-grpc >= 0.41b0",
84+
"opentelemetry-instrumentation-logging >= 0.41b0",
85+
]
86+
87+
# GenAI / AI model auto-instrumentation
88+
genai = [
89+
"opentelemetry-instrumentation-openai-v2 >= 2.0b0",
90+
"opentelemetry-instrumentation-anthropic >= 0.1b0",
91+
"opentelemetry-instrumentation-vertexai >= 0.1b0",
92+
"opentelemetry-instrumentation-google-genai >= 0.1b0",
93+
"opentelemetry-instrumentation-langchain >= 0.1b0",
7794
]
7895

7996
# Cross-service carrier propagation (SQS, Kafka, Celery, Redis)
@@ -84,7 +101,7 @@ carriers = [
84101

85102
# Everything
86103
all = [
87-
"botanu[sdk,instruments,carriers]",
104+
"botanu[sdk,instruments,genai,carriers]",
88105
]
89106

90107
# Development / CI
@@ -138,7 +155,13 @@ select = [
138155
ignore = [
139156
"E501", # line too long — handled by formatter
140157
"S101", # assert in tests is fine
158+
"S110", # try-except-pass is intentional in resource detection
159+
"UP006", # dict vs Dict — keep Dict[] for 3.9 compat
141160
"UP007", # X | Y syntax — keep Optional[] for 3.9 compat
161+
"UP035", # typing.Dict deprecated — keep for 3.9 compat
162+
"UP045", # X | None vs Optional — keep Optional[] for 3.9 compat
163+
"RUF002", # ambiguous dash — intentional in docstrings
164+
"RUF022", # __all__ not sorted — grouped logically
142165
]
143166

144167
[tool.ruff.lint.per-file-ignores]
@@ -154,10 +177,12 @@ line-ending = "auto"
154177
# ---------------------------------------------------------------------------
155178
[tool.mypy]
156179
python_version = "3.9"
157-
warn_return_any = true
180+
warn_return_any = false
158181
warn_unused_configs = true
159182
ignore_missing_imports = true
160183
strict = false
184+
# OTel SDK types are not always precise; runtime behavior is correct
185+
disable_error_code = ["arg-type", "attr-defined", "operator", "misc"]
161186

162187
# ---------------------------------------------------------------------------
163188
# pytest

src/botanu/__init__.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-FileCopyrightText: 2026 The Botanu Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Botanu SDK - OpenTelemetry-native cost attribution for AI workflows.
5+
6+
Quick Start::
7+
8+
from botanu import enable, botanu_use_case, emit_outcome
9+
10+
enable(service_name="my-app")
11+
12+
@botanu_use_case(name="Customer Support")
13+
async def handle_request(data):
14+
result = await process(data)
15+
emit_outcome("success", value_type="tickets_resolved", value_amount=1)
16+
return result
17+
"""
18+
19+
from __future__ import annotations
20+
21+
from botanu._version import __version__
22+
23+
# Run context model
24+
from botanu.models.run_context import RunContext, RunOutcome, RunStatus
25+
26+
# Bootstrap
27+
from botanu.sdk.bootstrap import (
28+
disable,
29+
enable,
30+
is_enabled,
31+
)
32+
33+
# Configuration
34+
from botanu.sdk.config import BotanuConfig
35+
36+
# Context helpers (core — no SDK dependency)
37+
from botanu.sdk.context import (
38+
get_baggage,
39+
get_current_span,
40+
get_run_id,
41+
get_use_case,
42+
set_baggage,
43+
)
44+
45+
# Decorators (primary integration point)
46+
from botanu.sdk.decorators import botanu_outcome, botanu_use_case, use_case
47+
48+
# Span helpers
49+
from botanu.sdk.span_helpers import emit_outcome, set_business_context
50+
51+
__all__ = [
52+
"__version__",
53+
# Bootstrap
54+
"enable",
55+
"disable",
56+
"is_enabled",
57+
# Configuration
58+
"BotanuConfig",
59+
# Decorators
60+
"botanu_use_case",
61+
"use_case",
62+
"botanu_outcome",
63+
# Span helpers
64+
"emit_outcome",
65+
"set_business_context",
66+
"get_current_span",
67+
# Context
68+
"get_run_id",
69+
"get_use_case",
70+
"set_baggage",
71+
"get_baggage",
72+
# Run context
73+
"RunContext",
74+
"RunStatus",
75+
"RunOutcome",
76+
]

src/botanu/_version.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2026 The Botanu Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Dynamic version from package metadata (set by hatch-vcs at build time)."""
5+
6+
from __future__ import annotations
7+
8+
try:
9+
from importlib.metadata import version
10+
11+
__version__: str = version("botanu")
12+
except Exception:
13+
__version__ = "0.0.0.dev0"

src/botanu/models/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-FileCopyrightText: 2026 The Botanu Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Botanu data models."""
5+
6+
from __future__ import annotations
7+
8+
from botanu.models.run_context import RunContext, RunOutcome, RunStatus
9+
10+
__all__ = ["RunContext", "RunOutcome", "RunStatus"]

0 commit comments

Comments
 (0)