anytrace 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anytrace-0.9.0/.env.example +18 -0
- anytrace-0.9.0/.github/workflows/ci.yml +62 -0
- anytrace-0.9.0/.github/workflows/release.yml +36 -0
- anytrace-0.9.0/.gitignore +13 -0
- anytrace-0.9.0/.vscode/settings.json +3 -0
- anytrace-0.9.0/CHANGELOG.md +183 -0
- anytrace-0.9.0/CLAUDE.md +74 -0
- anytrace-0.9.0/LICENSE +202 -0
- anytrace-0.9.0/Makefile +12 -0
- anytrace-0.9.0/PKG-INFO +360 -0
- anytrace-0.9.0/README.md +321 -0
- anytrace-0.9.0/SECURITY.md +25 -0
- anytrace-0.9.0/docs/PITCH.md +103 -0
- anytrace-0.9.0/docs/backend-verification.md +96 -0
- anytrace-0.9.0/docs/distributed-tracing.md +81 -0
- anytrace-0.9.0/docs/migration.md +63 -0
- anytrace-0.9.0/docs/tutorials/01-getting-started.ipynb +142 -0
- anytrace-0.9.0/docs/tutorials/02-tracing-llm-calls.ipynb +165 -0
- anytrace-0.9.0/docs/tutorials/03-rich-traces.ipynb +198 -0
- anytrace-0.9.0/docs/tutorials/04-framework-integrations.ipynb +170 -0
- anytrace-0.9.0/docs/tutorials/05-distributed-tracing.ipynb +170 -0
- anytrace-0.9.0/docs/tutorials/06-production-operations.ipynb +196 -0
- anytrace-0.9.0/docs/tutorials/07-multi-backend-and-migration.ipynb +169 -0
- anytrace-0.9.0/docs/tutorials/08-testing.ipynb +146 -0
- anytrace-0.9.0/docs/tutorials/09-rag-pipeline.ipynb +311 -0
- anytrace-0.9.0/docs/tutorials/README.md +28 -0
- anytrace-0.9.0/examples/README.md +23 -0
- anytrace-0.9.0/examples/comparison/1_langsmith_sdk.py +56 -0
- anytrace-0.9.0/examples/comparison/2_opentelemetry.py +99 -0
- anytrace-0.9.0/examples/comparison/2b_opentelemetry_langfuse.py +105 -0
- anytrace-0.9.0/examples/comparison/2c_opentelemetry_both.py +134 -0
- anytrace-0.9.0/examples/comparison/3_anytrace.py +79 -0
- anytrace-0.9.0/examples/comparison/README.md +124 -0
- anytrace-0.9.0/examples/comparison/financial_agent.py +81 -0
- anytrace-0.9.0/examples/comparison/requirements.txt +5 -0
- anytrace-0.9.0/examples/crewai_advanced/main.py +133 -0
- anytrace-0.9.0/examples/crewai_advanced/requirements.txt +2 -0
- anytrace-0.9.0/examples/crewai_app/main.py +86 -0
- anytrace-0.9.0/examples/crewai_app/requirements.txt +2 -0
- anytrace-0.9.0/examples/demo_traces.py +134 -0
- anytrace-0.9.0/examples/langchain_app/main.py +68 -0
- anytrace-0.9.0/examples/langchain_app/requirements.txt +2 -0
- anytrace-0.9.0/examples/langgraph_app/1_callback_handler.py +72 -0
- anytrace-0.9.0/examples/langgraph_app/2_manual_spans.py +60 -0
- anytrace-0.9.0/examples/langgraph_app/3_instrumented_client.py +91 -0
- anytrace-0.9.0/examples/langgraph_app/_shared.py +59 -0
- anytrace-0.9.0/examples/langgraph_app/requirements.txt +2 -0
- anytrace-0.9.0/examples/plain_python/main.py +98 -0
- anytrace-0.9.0/examples/plain_python/requirements.txt +2 -0
- anytrace-0.9.0/pyproject.toml +90 -0
- anytrace-0.9.0/src/anytrace/__init__.py +50 -0
- anytrace-0.9.0/src/anytrace/adapters/__init__.py +33 -0
- anytrace-0.9.0/src/anytrace/adapters/base.py +36 -0
- anytrace-0.9.0/src/anytrace/adapters/langfuse.py +80 -0
- anytrace-0.9.0/src/anytrace/adapters/langsmith.py +88 -0
- anytrace-0.9.0/src/anytrace/adapters/otlp.py +36 -0
- anytrace-0.9.0/src/anytrace/adapters/phoenix.py +71 -0
- anytrace-0.9.0/src/anytrace/adapters/processor.py +48 -0
- anytrace-0.9.0/src/anytrace/config/__init__.py +10 -0
- anytrace-0.9.0/src/anytrace/config/loader.py +282 -0
- anytrace-0.9.0/src/anytrace/context/__init__.py +5 -0
- anytrace-0.9.0/src/anytrace/context/middleware.py +79 -0
- anytrace-0.9.0/src/anytrace/context/propagation.py +75 -0
- anytrace-0.9.0/src/anytrace/core/__init__.py +44 -0
- anytrace-0.9.0/src/anytrace/core/generation.py +72 -0
- anytrace-0.9.0/src/anytrace/core/logs.py +41 -0
- anytrace-0.9.0/src/anytrace/core/spans.py +295 -0
- anytrace-0.9.0/src/anytrace/core/tracer.py +249 -0
- anytrace-0.9.0/src/anytrace/integrations/__init__.py +8 -0
- anytrace-0.9.0/src/anytrace/integrations/anthropic.py +74 -0
- anytrace-0.9.0/src/anytrace/integrations/crewai.py +297 -0
- anytrace-0.9.0/src/anytrace/integrations/langchain.py +257 -0
- anytrace-0.9.0/src/anytrace/integrations/openai.py +110 -0
- anytrace-0.9.0/src/anytrace/migrate/__init__.py +13 -0
- anytrace-0.9.0/src/anytrace/migrate/checkpoint.py +35 -0
- anytrace-0.9.0/src/anytrace/migrate/cli.py +159 -0
- anytrace-0.9.0/src/anytrace/migrate/http.py +52 -0
- anytrace-0.9.0/src/anytrace/migrate/model.py +34 -0
- anytrace-0.9.0/src/anytrace/migrate/readers.py +273 -0
- anytrace-0.9.0/src/anytrace/migrate/verify.py +125 -0
- anytrace-0.9.0/src/anytrace/migrate/writer.py +116 -0
- anytrace-0.9.0/src/anytrace/py.typed +0 -0
- anytrace-0.9.0/src/anytrace/testing.py +47 -0
- anytrace-0.9.0/tasks/epic-1-scaffold.md +21 -0
- anytrace-0.9.0/tasks/epic-10-cloud-providers.md +46 -0
- anytrace-0.9.0/tasks/epic-12-migration.md +82 -0
- anytrace-0.9.0/tasks/epic-2-config.md +21 -0
- anytrace-0.9.0/tasks/epic-3-core.md +42 -0
- anytrace-0.9.0/tasks/epic-4-adapters.md +43 -0
- anytrace-0.9.0/tasks/epic-5-distributed.md +27 -0
- anytrace-0.9.0/tasks/epic-6-docs.md +26 -0
- anytrace-0.9.0/tasks/epic-7-followups.md +50 -0
- anytrace-0.9.0/tasks/epic-8-sdk-parity.md +72 -0
- anytrace-0.9.0/tasks/epic-9-production-hardening.md +102 -0
- anytrace-0.9.0/tests/__init__.py +0 -0
- anytrace-0.9.0/tests/conftest.py +50 -0
- anytrace-0.9.0/tests/integration/__init__.py +0 -0
- anytrace-0.9.0/tests/integration/test_backends_live.py +130 -0
- anytrace-0.9.0/tests/integration/test_e2e_live.py +62 -0
- anytrace-0.9.0/tests/test_adapters.py +235 -0
- anytrace-0.9.0/tests/test_config.py +149 -0
- anytrace-0.9.0/tests/test_core_init.py +77 -0
- anytrace-0.9.0/tests/test_crewai_integration.py +75 -0
- anytrace-0.9.0/tests/test_e2e_distributed.py +69 -0
- anytrace-0.9.0/tests/test_epic9_extras.py +248 -0
- anytrace-0.9.0/tests/test_generation.py +78 -0
- anytrace-0.9.0/tests/test_hardening.py +311 -0
- anytrace-0.9.0/tests/test_langchain_integration.py +111 -0
- anytrace-0.9.0/tests/test_middleware.py +92 -0
- anytrace-0.9.0/tests/test_migrate.py +187 -0
- anytrace-0.9.0/tests/test_propagation.py +54 -0
- anytrace-0.9.0/tests/test_scaffold.py +52 -0
- anytrace-0.9.0/tests/test_sdk_parity.py +254 -0
- anytrace-0.9.0/tests/test_spans.py +137 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copy to .env and fill in real values. Never commit .env.
|
|
2
|
+
TRACING_BACKEND=langfuse # comma-separated: langsmith,langfuse
|
|
3
|
+
TRACING_SERVICE_NAME=my-agent
|
|
4
|
+
TRACING_ENVIRONMENT=development
|
|
5
|
+
TRACING_CAPTURE_CONTENT=false
|
|
6
|
+
|
|
7
|
+
# Langfuse (Basic auth pair)
|
|
8
|
+
LANGFUSE_ENDPOINT=https://us.cloud.langfuse.com
|
|
9
|
+
LANGFUSE_PUBLIC_KEY=pk-lf-xxxxxxxx
|
|
10
|
+
LANGFUSE_SECRET_KEY=sk-lf-xxxxxxxx
|
|
11
|
+
|
|
12
|
+
# LangSmith (use a Personal Access Token, lsv2_pt_...)
|
|
13
|
+
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
|
|
14
|
+
LANGSMITH_API_KEY=lsv2_pt_xxxxxxxx
|
|
15
|
+
|
|
16
|
+
# Arize Phoenix (api key only for Phoenix Cloud; self-hosted needs none)
|
|
17
|
+
PHOENIX_ENDPOINT=https://app.phoenix.arize.com/s/your-space
|
|
18
|
+
PHOENIX_API_KEY=eyJxxxxxxxx
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
checks:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install
|
|
21
|
+
run: pip install -e ".[dev]"
|
|
22
|
+
- name: Lint (ruff)
|
|
23
|
+
run: ruff check .
|
|
24
|
+
- name: Types (mypy strict)
|
|
25
|
+
run: mypy
|
|
26
|
+
- name: Tests
|
|
27
|
+
run: pytest
|
|
28
|
+
|
|
29
|
+
examples-offline:
|
|
30
|
+
# Examples that need no credentials: spans go to a console/in-memory
|
|
31
|
+
# exporter or are dropped fail-open when no backend is configured.
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: actions/setup-python@v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- name: Install
|
|
39
|
+
run: pip install -e . langchain-core
|
|
40
|
+
- name: Plain Python example
|
|
41
|
+
run: python examples/plain_python/main.py
|
|
42
|
+
env:
|
|
43
|
+
TRACING_BACKEND: ""
|
|
44
|
+
- name: LangChain integration example
|
|
45
|
+
run: python examples/langchain_app/main.py
|
|
46
|
+
env:
|
|
47
|
+
TRACING_BACKEND: ""
|
|
48
|
+
|
|
49
|
+
build:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
- uses: actions/setup-python@v5
|
|
54
|
+
with:
|
|
55
|
+
python-version: "3.12"
|
|
56
|
+
- name: Build sdist + wheel
|
|
57
|
+
run: pipx run build
|
|
58
|
+
- name: Install from wheel & import
|
|
59
|
+
run: |
|
|
60
|
+
pip install dist/*.whl
|
|
61
|
+
python -c "import anytrace; print(anytrace.__name__, 'ok')"
|
|
62
|
+
anytrace-migrate --help >/dev/null
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-python@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.12"
|
|
16
|
+
- name: Build sdist + wheel
|
|
17
|
+
run: pipx run build
|
|
18
|
+
- uses: actions/upload-artifact@v4
|
|
19
|
+
with:
|
|
20
|
+
name: dist
|
|
21
|
+
path: dist/
|
|
22
|
+
|
|
23
|
+
publish:
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment:
|
|
27
|
+
name: pypi
|
|
28
|
+
url: https://pypi.org/p/anytrace
|
|
29
|
+
permissions:
|
|
30
|
+
id-token: write # OIDC for PyPI trusted publishing
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/download-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: dist
|
|
35
|
+
path: dist/
|
|
36
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to anytrace. Follows [Keep a Changelog](https://keepachangelog.com)
|
|
4
|
+
and semantic versioning.
|
|
5
|
+
|
|
6
|
+
## [0.9.0] - 2026-07-20
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- **Full rename `tracelib` → `anytrace`** — the import name, CLI, and all
|
|
10
|
+
public classes now use `anytrace`:
|
|
11
|
+
`import tracelib` → `import anytrace`; `tracelib-migrate` → `anytrace-migrate`
|
|
12
|
+
(checkpoint file `.anytrace-migrate.json`);
|
|
13
|
+
`TracelibCallbackHandler` → `AnytraceCallbackHandler`;
|
|
14
|
+
`TracelibCrewListener` → `AnytraceCrewListener`;
|
|
15
|
+
inherited tag attribute `tracelib.tags` → `anytrace.tags`.
|
|
16
|
+
Env vars (`TRACING_*`, backend creds) are unchanged.
|
|
17
|
+
|
|
18
|
+
## [0.8.0] - 2026-07-20
|
|
19
|
+
|
|
20
|
+
First public release, on GitHub as
|
|
21
|
+
[`anytrace`](https://github.com/hitesh-balapanuru/anytrace).
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Distribution renamed `tracelib` → **`anytrace`** (at 0.8.0 the import name
|
|
25
|
+
was still `tracelib`; 0.9.0 completed the rename).
|
|
26
|
+
- License changed to **Apache-2.0** (LICENSE file added).
|
|
27
|
+
- Docs sanitized for public release; SECURITY.md rewritten as a general
|
|
28
|
+
credential-handling and vulnerability-reporting policy.
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- `py.typed` marker — type checkers now consume anytrace's inline annotations.
|
|
32
|
+
- GitHub Actions CI: ruff + mypy strict + pytest on Python 3.10/3.13,
|
|
33
|
+
credential-free example runs, and a build-and-import smoke test.
|
|
34
|
+
|
|
35
|
+
## [0.7.0] - 2026-07-19
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- **`anytrace-migrate`**: batch backfill of historical traces between backends
|
|
39
|
+
(`anytrace.migrate`, stdlib-only). Readers for LangSmith/Langfuse (Phoenix
|
|
40
|
+
experimental) with exponential backoff; replay through the production adapter
|
|
41
|
+
pipeline with ORIGINAL timestamps, deterministic ids, and provenance
|
|
42
|
+
attributes; source-side checkpointing (`--resume`) since destination OTLP
|
|
43
|
+
ingestion appends rather than upserts; `--verify N` polls the destination
|
|
44
|
+
read API (2xx ≠ ingested); `--dry-run`, `--no-content`, throttling.
|
|
45
|
+
Both LangSmith↔Langfuse directions live-verified. See docs/migration.md.
|
|
46
|
+
|
|
47
|
+
## [0.6.1] - 2026-07-18
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
- Masking now also applies to custom attribute values (`add_metadata()`,
|
|
51
|
+
`trace_span`/`trace_tool` kwargs, `add_event()` attributes) — previously only
|
|
52
|
+
prompts/completions/`set_io` were masked, so PII in metadata went out
|
|
53
|
+
unredacted. Identifiers (`set_user`/`set_session`/`add_tags`) are
|
|
54
|
+
deliberately not masked to keep filtering intact.
|
|
55
|
+
|
|
56
|
+
## [0.6.0] - 2026-07-17
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
- **CrewAI auto-instrumentation**: `AnytraceCrewListener`
|
|
60
|
+
(`anytrace.integrations.crewai`) — hooks CrewAI's event bus; crew/task/
|
|
61
|
+
agent/tool/LLM events become typed, nested spans with per-call token usage.
|
|
62
|
+
Thread-safe explicit parenting via CrewAI event ids (events fire from worker
|
|
63
|
+
threads, so ambient-context parenting cannot work). Live-verified: 3-agent
|
|
64
|
+
investment-memo crew rendered as one 15-span trace in LangSmith, Langfuse,
|
|
65
|
+
and Phoenix simultaneously.
|
|
66
|
+
- `examples/crewai_advanced/` — the investment-memo crew demo (three agents,
|
|
67
|
+
three tools, real Claude calls, zero manual spans).
|
|
68
|
+
|
|
69
|
+
## [0.5.1] - 2026-07-16
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
- Phoenix Cloud authentication: the `api_key` header alone returns 401; the
|
|
73
|
+
adapter now sends `Authorization: Bearer` (plus the legacy header for older
|
|
74
|
+
self-hosted deployments). Found during live verification — Phoenix rendering
|
|
75
|
+
confirmed end-to-end (span kinds, tokens, tags, user/session).
|
|
76
|
+
|
|
77
|
+
## [0.5.0] - 2026-07-16
|
|
78
|
+
|
|
79
|
+
Epic 9 completed (stories 9.6–9.10).
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- **Arize Phoenix adapter** (`TRACING_BACKEND=phoenix`): OpenInference dialect
|
|
83
|
+
mapping (span kinds, model, token counts, I/O values, tags); optional
|
|
84
|
+
`PHOENIX_API_KEY` for Phoenix Cloud. Third backend proves the neutrality
|
|
85
|
+
claim — three-way fan-out covered by tests.
|
|
86
|
+
- **Generic `otlp` backend**: passthrough adapter for any OTel Collector or
|
|
87
|
+
OTLP receiver (`OTLP_ENDPOINT`, optional `OTLP_HEADERS="k=v,..."`).
|
|
88
|
+
- **`add_event(name, **attrs)`**: point-in-time span events.
|
|
89
|
+
- **Release/version tagging**: `TRACING_RELEASE` / `TRACING_VERSION` stamped on
|
|
90
|
+
every span and mapped per backend (`langfuse.release`, LangSmith metadata,
|
|
91
|
+
`service.version` resource attribute).
|
|
92
|
+
- **`anytrace.testing.capture()`**: in-memory span capture for application test
|
|
93
|
+
suites; `trace_agent()` / `trace_chain()` complete the typing set.
|
|
94
|
+
- **gRPC transport**: `TRACING_PROTOCOL=grpc` with the `anytrace[grpc]` extra
|
|
95
|
+
(collector use); collector deployment guidance in the README.
|
|
96
|
+
|
|
97
|
+
## [0.4.0] - 2026-07-16
|
|
98
|
+
|
|
99
|
+
Production hardening (epic 9, stories 9.1–9.5).
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
- **Fail-open**: using anytrace before `init()` is now a silent no-op instead
|
|
103
|
+
of raising RuntimeError (one-time DEBUG log). `TRACING_ENABLED=false` is a
|
|
104
|
+
kill switch; a crashing mask hook redacts content instead of propagating.
|
|
105
|
+
|
|
106
|
+
### Added
|
|
107
|
+
- **W3C Baggage propagation**: `inject_context`/`use_context` (and the
|
|
108
|
+
middleware) carry user/session/tags across service boundaries, not just the
|
|
109
|
+
trace id.
|
|
110
|
+
- **LLM client auto-instrumentation**: `anytrace.integrations.anthropic` /
|
|
111
|
+
`.openai` `instrument(client)` — generation spans with model, temperature,
|
|
112
|
+
tokens, and content, sync + async, duck-typed (no SDK dependencies).
|
|
113
|
+
Live-verified: tokens auto-captured in both backends.
|
|
114
|
+
- **Log correlation**: `anytrace.instrument_logging()` stamps
|
|
115
|
+
trace_id/span_id/user_id/session_id onto every LogRecord.
|
|
116
|
+
- **Self-diagnostics**: `anytrace.stats()` per-backend exported/failed
|
|
117
|
+
counters; `shutdown()` warns on export failures; `TRACING_STRICT=true`
|
|
118
|
+
fails `init()` fast on an unreachable backend.
|
|
119
|
+
|
|
120
|
+
## [0.3.0] - 2026-07-15
|
|
121
|
+
|
|
122
|
+
Vendor-SDK tracing parity (epic 8, stories 8.1–8.7). All rendering changes
|
|
123
|
+
live-verified in Langfuse and LangSmith cloud.
|
|
124
|
+
|
|
125
|
+
### Added
|
|
126
|
+
- **LangChain/LangGraph auto-instrumentation**: `AnytraceCallbackHandler`
|
|
127
|
+
(`anytrace.integrations.langchain`) traces chains, LLMs, tools, and
|
|
128
|
+
retrievers with zero manual spans — typed, nested, with token usage.
|
|
129
|
+
`langchain-core` stays out of anytrace's dependencies.
|
|
130
|
+
- **Typed spans**: `trace_tool()`, `trace_retriever()`, `trace_embedding()`
|
|
131
|
+
emit GenAI `operation.name` attributes; adapters translate to LangSmith run
|
|
132
|
+
types (tool/retriever/embedding) and Langfuse observation types.
|
|
133
|
+
- **`set_io(input=, output=)`**: record I/O on any span (roots included),
|
|
134
|
+
capture-gated and masked; feeds backend inputs/outputs and thread views.
|
|
135
|
+
- **`add_tags(*tags)`**: context-inherited tags → `langsmith.span.tags` /
|
|
136
|
+
`langfuse.trace.tags`.
|
|
137
|
+
- **LangSmith project routing**: `LANGSMITH_PROJECT` → `Langsmith-Project`
|
|
138
|
+
header (auto-creates the project).
|
|
139
|
+
- **Sampling**: `TRACING_SAMPLE_RATE` (parent-based ratio sampler, distributed-safe).
|
|
140
|
+
- **Content masking**: `init(mask=callable)` or `TRACING_MASK_PATTERNS`
|
|
141
|
+
regexes applied to all captured content (`set_content`, `set_io`, handler).
|
|
142
|
+
|
|
143
|
+
### Not included
|
|
144
|
+
- Story 8.8 (time-to-first-token, scores-from-code) — not started.
|
|
145
|
+
|
|
146
|
+
## [0.2.0] - 2026-07-15
|
|
147
|
+
|
|
148
|
+
### Added
|
|
149
|
+
- Per-call content-capture override: `record_generation(..., capture_content=True/False)`
|
|
150
|
+
overrides the process-wide `TRACING_CAPTURE_CONTENT` for a single call.
|
|
151
|
+
- `SECURITY.md` (credential handling + rotation steps) and `.env.example`.
|
|
152
|
+
|
|
153
|
+
### Fixed (attribute-mapping gaps from the backend docs audit, live-verified)
|
|
154
|
+
- Custom attributes (`add_metadata()`, `trace_span(**attrs)`) are now mirrored to
|
|
155
|
+
first-class backend metadata: `langsmith.metadata.<key>` and
|
|
156
|
+
`langfuse.observation.metadata.<key>` (previously dropped by LangSmith).
|
|
157
|
+
- Reported `gen_ai.usage.cost` is mirrored to `langsmith.metadata.cost`
|
|
158
|
+
(LangSmith ignores the standard attribute and computes its own price).
|
|
159
|
+
|
|
160
|
+
## [0.1.0] - 2026-07-15
|
|
161
|
+
|
|
162
|
+
Initial release.
|
|
163
|
+
|
|
164
|
+
### Added
|
|
165
|
+
- Core API: `init()` / `shutdown()`, `trace_span()`, `@traced()` (sync + async),
|
|
166
|
+
`record_generation()` with usage/cost and opt-in content capture,
|
|
167
|
+
`set_user()` / `set_session()` (inherited by child spans), `add_metadata()`.
|
|
168
|
+
- Config layer: env-var driven (`TRACING_*`), optional YAML override via
|
|
169
|
+
`TRACING_CONFIG_FILE`, multi-backend fan-out, secret redaction in `repr`.
|
|
170
|
+
- Backend adapters over pure OTLP (no vendor SDKs): LangSmith (`x-api-key`,
|
|
171
|
+
`langsmith.span.kind`/metadata mapping) and Langfuse (Basic auth,
|
|
172
|
+
generation typing, `langfuse.user.id`/`session.id` mapping), with per-backend
|
|
173
|
+
attribute dialects applied at export time.
|
|
174
|
+
- Distributed tracing: W3C `traceparent` extract/inject/use helpers plus
|
|
175
|
+
FastAPI middleware and Flask hooks (import-guarded examples).
|
|
176
|
+
- Docs: distributed-tracing guide, live backend-verification checklist
|
|
177
|
+
(both backends verified against cloud instances), migration guides.
|
|
178
|
+
- Examples: plain Python, LangChain, LangGraph, CrewAI — all offline-runnable.
|
|
179
|
+
|
|
180
|
+
### Known limitations
|
|
181
|
+
- LangSmith drops traces whose root span never arrives (browser-minted
|
|
182
|
+
`traceparent` without a UI exporter) — see docs/distributed-tracing.md.
|
|
183
|
+
- Content capture is all-or-nothing per process (`TRACING_CAPTURE_CONTENT`).
|
anytrace-0.9.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# CLAUDE.md — Vendor-Neutral Agent Tracing Library
|
|
2
|
+
|
|
3
|
+
## What this project is
|
|
4
|
+
|
|
5
|
+
A Python library (distribution: "anytrace", import: "anytrace") that gives all agent/application
|
|
6
|
+
teams a single, vendor-neutral tracing API. It is a **thin wrapper over the OpenTelemetry SDK**,
|
|
7
|
+
standardized on **OpenTelemetry GenAI semantic conventions**, with pluggable backend adapters
|
|
8
|
+
for LangSmith (self-hosted) and Langfuse (self-hosted OSS). Switching or adding a backend must
|
|
9
|
+
require **zero code changes** in applications — configuration only.
|
|
10
|
+
|
|
11
|
+
## Non-negotiable requirements
|
|
12
|
+
|
|
13
|
+
1. **Framework agnostic**: must work with LangChain, LangGraph, CrewAI, and plain Python.
|
|
14
|
+
Never import or depend on any agent framework in the core library.
|
|
15
|
+
2. **Vendor agnostic**: no vendor SDKs (`langsmith`, `langfuse` packages are FORBIDDEN as
|
|
16
|
+
dependencies). Talk to backends only via OTLP export with backend-specific attribute
|
|
17
|
+
mapping and headers.
|
|
18
|
+
3. **Config-driven backend selection**: env vars first, optional YAML override. Applications
|
|
19
|
+
never reference a backend in code.
|
|
20
|
+
4. **GenAI semantic conventions** are the internal standard. Teams emit `gen_ai.*` attributes;
|
|
21
|
+
adapters translate per backend.
|
|
22
|
+
5. **Distributed tracing**: W3C Trace Context propagation across services and languages.
|
|
23
|
+
6. **Scope = tracing only**: no prompt management, no evaluations in v1.
|
|
24
|
+
|
|
25
|
+
## Architecture
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Application code
|
|
29
|
+
│ (core API: init, trace, record_generation, set_user/session, extract/inject context)
|
|
30
|
+
▼
|
|
31
|
+
core/ ── emits OTel spans with gen_ai.* attributes
|
|
32
|
+
▼
|
|
33
|
+
adapters/ ── SpanProcessor/exporter config per backend; maps attributes + endpoint + auth
|
|
34
|
+
▼
|
|
35
|
+
OTLP endpoint (LangSmith | Langfuse | future: Grafana, Arize Phoenix, ...)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Modules:
|
|
39
|
+
- `src/anytrace/core/` — tracer setup, span helpers, generation recording, error capture
|
|
40
|
+
- `src/anytrace/adapters/` — `base.py` (interface), `langsmith.py`, `langfuse.py`
|
|
41
|
+
- `src/anytrace/config/` — env/YAML loader + validation
|
|
42
|
+
- `src/anytrace/context/` — W3C propagation helpers + framework middleware examples
|
|
43
|
+
|
|
44
|
+
## Key attribute mappings (adapters)
|
|
45
|
+
|
|
46
|
+
Internal (GenAI) → backend:
|
|
47
|
+
- `gen_ai.request.model`, `gen_ai.request.temperature`, `gen_ai.usage.input_tokens`,
|
|
48
|
+
`gen_ai.usage.output_tokens`, `gen_ai.system` — pass through to both backends.
|
|
49
|
+
- Langfuse extras: set `langfuse.observation.type = "generation"` on LLM-call spans;
|
|
50
|
+
map user → `langfuse.user_id`, session → `langfuse.session_id`. Auth: Basic (public/secret key).
|
|
51
|
+
- LangSmith: OpenLLMetry-style attributes where required; auth via `x-api-key` header;
|
|
52
|
+
OTLP endpoint path per LangSmith self-hosted docs.
|
|
53
|
+
- Verify current attribute expectations against each backend's docs before finalizing —
|
|
54
|
+
conventions are still evolving; keep every mapping in ONE table per adapter file.
|
|
55
|
+
|
|
56
|
+
## Engineering conventions
|
|
57
|
+
|
|
58
|
+
- Python 3.10+, `src/` layout, `pyproject.toml`, hatchling or setuptools.
|
|
59
|
+
- Lint/format: ruff. Types: mypy (strict on `core/` and `adapters/`).
|
|
60
|
+
- Tests: pytest. Every story lands with tests. Use OTel `InMemorySpanExporter` for unit tests;
|
|
61
|
+
integration tests hit real self-hosted instances behind env-var gates
|
|
62
|
+
(`ITEST_LANGFUSE=1`, `ITEST_LANGSMITH=1`) and are skipped otherwise.
|
|
63
|
+
- Public API surface is ONLY what's exported from `anytrace/__init__.py`. Keep it small.
|
|
64
|
+
- Content capture (prompts/completions) must be OFF by default; enable via
|
|
65
|
+
`TRACING_CAPTURE_CONTENT=true`. Never log secrets.
|
|
66
|
+
- Semantic versioning; changelog per release.
|
|
67
|
+
|
|
68
|
+
## Workflow for Claude Code
|
|
69
|
+
|
|
70
|
+
- Work through `tasks/epic-*.md` in order. Within an epic, complete stories top to bottom.
|
|
71
|
+
- Definition of done per story: code + tests passing (`pytest`), lint clean (`ruff check`),
|
|
72
|
+
types clean (`mypy`), and the story's acceptance criteria checked off in the task file.
|
|
73
|
+
- Do not start a new epic with failing tests in the previous one.
|
|
74
|
+
- Ask before adding any new runtime dependency beyond opentelemetry packages.
|
anytrace-0.9.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|