debrix 0.1.0a1__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.
- debrix-0.1.0a1/.github/workflows/publish.yml +47 -0
- debrix-0.1.0a1/.gitignore +12 -0
- debrix-0.1.0a1/LICENSE +21 -0
- debrix-0.1.0a1/PKG-INFO +110 -0
- debrix-0.1.0a1/README.md +82 -0
- debrix-0.1.0a1/pyproject.toml +47 -0
- debrix-0.1.0a1/src/debrix/__init__.py +23 -0
- debrix-0.1.0a1/src/debrix/config.py +115 -0
- debrix-0.1.0a1/src/debrix/payloads.py +279 -0
- debrix-0.1.0a1/src/debrix/py.typed +0 -0
- debrix-0.1.0a1/src/debrix/semconv.py +83 -0
- debrix-0.1.0a1/src/debrix/span.py +243 -0
- debrix-0.1.0a1/src/debrix/tracing.py +327 -0
- debrix-0.1.0a1/tests/conftest.py +48 -0
- debrix-0.1.0a1/tests/test_config.py +24 -0
- debrix-0.1.0a1/tests/test_payloads.py +310 -0
- debrix-0.1.0a1/tests/test_semconv.py +55 -0
- debrix-0.1.0a1/tests/test_tracing.py +243 -0
- debrix-0.1.0a1/tests/test_version.py +5 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
|
|
21
|
+
- name: Install package + test deps
|
|
22
|
+
run: pip install -e ".[dev]"
|
|
23
|
+
|
|
24
|
+
- name: Run tests
|
|
25
|
+
run: pytest -q
|
|
26
|
+
|
|
27
|
+
publish:
|
|
28
|
+
needs: test
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
environment: pypi
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
|
|
34
|
+
- uses: actions/setup-python@v5
|
|
35
|
+
with:
|
|
36
|
+
python-version: "3.12"
|
|
37
|
+
|
|
38
|
+
- name: Install build tools
|
|
39
|
+
run: pip install build
|
|
40
|
+
|
|
41
|
+
- name: Build sdist and wheel
|
|
42
|
+
run: python -m build
|
|
43
|
+
|
|
44
|
+
- name: Publish to PyPI
|
|
45
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
46
|
+
with:
|
|
47
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
debrix-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Debrix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
debrix-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: debrix
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Open-source instrumentation SDK for Debrix — local-first AI Agent DevTools
|
|
5
|
+
Project-URL: Homepage, https://github.com/goyal-prateek/debrix-sdk
|
|
6
|
+
Project-URL: Repository, https://github.com/goyal-prateek/debrix-sdk
|
|
7
|
+
Project-URL: Issues, https://github.com/goyal-prateek/debrix-sdk/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/goyal-prateek/debrix-sdk#readme
|
|
9
|
+
Author-email: Prateek Goyal <gprateek015@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,debrix,observability,opentelemetry,tracing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: opentelemetry-api>=1.27.0
|
|
23
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.27.0
|
|
24
|
+
Requires-Dist: opentelemetry-sdk>=1.27.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# debrix
|
|
30
|
+
|
|
31
|
+
Open-source instrumentation SDK for [Debrix](https://github.com/goyal-prateek/debrix-sdk) — local-first AI Agent DevTools.
|
|
32
|
+
|
|
33
|
+
**Status:** alpha (`0.1.0a1`). APIs may change.
|
|
34
|
+
|
|
35
|
+
Requires the Debrix desktop app running locally to receive traces (OTLP/HTTP on `localhost:4318`).
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install debrix
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
TestPyPI (pre-release smoke):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ debrix==0.1.0a1
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from debrix import configure, force_flush, trace_agent, trace_tool, trace_span, SpanKind
|
|
53
|
+
|
|
54
|
+
configure(batch=False) # OTLP/HTTP → http://127.0.0.1:4318
|
|
55
|
+
|
|
56
|
+
@trace_agent
|
|
57
|
+
def run_agent(query: str) -> str:
|
|
58
|
+
return research(query)
|
|
59
|
+
|
|
60
|
+
@trace_tool(name="search")
|
|
61
|
+
def research(query: str) -> str:
|
|
62
|
+
with trace_span("complete", kind=SpanKind.LLM) as span:
|
|
63
|
+
span.record_messages([
|
|
64
|
+
{"role": "system", "content": "You are helpful."},
|
|
65
|
+
{"role": "user", "content": query},
|
|
66
|
+
])
|
|
67
|
+
answer = "..."
|
|
68
|
+
span.record_response({
|
|
69
|
+
"content": answer,
|
|
70
|
+
"usage": {"input_tokens": 10, "output_tokens": 5},
|
|
71
|
+
})
|
|
72
|
+
return answer
|
|
73
|
+
|
|
74
|
+
run_agent("hello")
|
|
75
|
+
force_flush() # flush OTLP *and* conversation payload uploads before exit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Decorators also work as context managers:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
with trace_agent("planner") as span:
|
|
82
|
+
with trace_tool("lookup"):
|
|
83
|
+
...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Public API
|
|
87
|
+
|
|
88
|
+
| Symbol | Purpose |
|
|
89
|
+
| ------ | ------- |
|
|
90
|
+
| `configure()` | Install OTLP/HTTP exporter to Debrix (`:4318`) |
|
|
91
|
+
| `force_flush()` | Flush OTLP spans + pending `/v1/payloads` uploads (call before short scripts exit) |
|
|
92
|
+
| `trace_agent` | Agent boundary (decorator or `with trace_agent("name")`) |
|
|
93
|
+
| `trace_tool` | Tool call span; decorator records `debrix.replay.input` / `output` |
|
|
94
|
+
| `trace_span` | Generic / LLM / custom span context manager |
|
|
95
|
+
| `DebrixSpan.record_messages(...)` | Opt-in message payloads |
|
|
96
|
+
| `DebrixSpan.record_response(...)` | Opt-in model output / tokens |
|
|
97
|
+
| `SpanKind`, `Attr` | Semantic convention constants |
|
|
98
|
+
|
|
99
|
+
Nested calls propagate via OpenTelemetry context. On exception, spans are marked `ERROR` with `debrix.error.summary`.
|
|
100
|
+
|
|
101
|
+
## Develop
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
uv sync --group dev
|
|
105
|
+
uv run pytest
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT
|
debrix-0.1.0a1/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# debrix
|
|
2
|
+
|
|
3
|
+
Open-source instrumentation SDK for [Debrix](https://github.com/goyal-prateek/debrix-sdk) — local-first AI Agent DevTools.
|
|
4
|
+
|
|
5
|
+
**Status:** alpha (`0.1.0a1`). APIs may change.
|
|
6
|
+
|
|
7
|
+
Requires the Debrix desktop app running locally to receive traces (OTLP/HTTP on `localhost:4318`).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install debrix
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
TestPyPI (pre-release smoke):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ debrix==0.1.0a1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from debrix import configure, force_flush, trace_agent, trace_tool, trace_span, SpanKind
|
|
25
|
+
|
|
26
|
+
configure(batch=False) # OTLP/HTTP → http://127.0.0.1:4318
|
|
27
|
+
|
|
28
|
+
@trace_agent
|
|
29
|
+
def run_agent(query: str) -> str:
|
|
30
|
+
return research(query)
|
|
31
|
+
|
|
32
|
+
@trace_tool(name="search")
|
|
33
|
+
def research(query: str) -> str:
|
|
34
|
+
with trace_span("complete", kind=SpanKind.LLM) as span:
|
|
35
|
+
span.record_messages([
|
|
36
|
+
{"role": "system", "content": "You are helpful."},
|
|
37
|
+
{"role": "user", "content": query},
|
|
38
|
+
])
|
|
39
|
+
answer = "..."
|
|
40
|
+
span.record_response({
|
|
41
|
+
"content": answer,
|
|
42
|
+
"usage": {"input_tokens": 10, "output_tokens": 5},
|
|
43
|
+
})
|
|
44
|
+
return answer
|
|
45
|
+
|
|
46
|
+
run_agent("hello")
|
|
47
|
+
force_flush() # flush OTLP *and* conversation payload uploads before exit
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Decorators also work as context managers:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
with trace_agent("planner") as span:
|
|
54
|
+
with trace_tool("lookup"):
|
|
55
|
+
...
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Public API
|
|
59
|
+
|
|
60
|
+
| Symbol | Purpose |
|
|
61
|
+
| ------ | ------- |
|
|
62
|
+
| `configure()` | Install OTLP/HTTP exporter to Debrix (`:4318`) |
|
|
63
|
+
| `force_flush()` | Flush OTLP spans + pending `/v1/payloads` uploads (call before short scripts exit) |
|
|
64
|
+
| `trace_agent` | Agent boundary (decorator or `with trace_agent("name")`) |
|
|
65
|
+
| `trace_tool` | Tool call span; decorator records `debrix.replay.input` / `output` |
|
|
66
|
+
| `trace_span` | Generic / LLM / custom span context manager |
|
|
67
|
+
| `DebrixSpan.record_messages(...)` | Opt-in message payloads |
|
|
68
|
+
| `DebrixSpan.record_response(...)` | Opt-in model output / tokens |
|
|
69
|
+
| `SpanKind`, `Attr` | Semantic convention constants |
|
|
70
|
+
|
|
71
|
+
Nested calls propagate via OpenTelemetry context. On exception, spans are marked `ERROR` with `debrix.error.summary`.
|
|
72
|
+
|
|
73
|
+
## Develop
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv sync --group dev
|
|
77
|
+
uv run pytest
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "debrix"
|
|
3
|
+
version = "0.1.0a1"
|
|
4
|
+
description = "Open-source instrumentation SDK for Debrix — local-first AI Agent DevTools"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
authors = [{ name = "Prateek Goyal", email = "gprateek015@gmail.com" }]
|
|
9
|
+
keywords = ["observability", "opentelemetry", "agents", "tracing", "debrix"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Topic :: Software Development :: Debuggers",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"opentelemetry-api>=1.27.0",
|
|
22
|
+
"opentelemetry-sdk>=1.27.0",
|
|
23
|
+
"opentelemetry-exporter-otlp-proto-http>=1.27.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest>=8.0"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/goyal-prateek/debrix-sdk"
|
|
31
|
+
Repository = "https://github.com/goyal-prateek/debrix-sdk"
|
|
32
|
+
Issues = "https://github.com/goyal-prateek/debrix-sdk/issues"
|
|
33
|
+
Documentation = "https://github.com/goyal-prateek/debrix-sdk#readme"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["hatchling"]
|
|
37
|
+
build-backend = "hatchling.build"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.wheel]
|
|
40
|
+
packages = ["src/debrix"]
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = ["pytest>=8.0"]
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
testpaths = ["tests"]
|
|
47
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Debrix — open-source instrumentation SDK for AI agents."""
|
|
2
|
+
|
|
3
|
+
from debrix.config import configure, force_flush
|
|
4
|
+
from debrix.semconv import SPAN_KINDS, Attr, Event, SpanKind
|
|
5
|
+
from debrix.span import DebrixSpan
|
|
6
|
+
from debrix.tracing import get_tracer, trace_agent, trace_span, trace_tool
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0a1"
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"__version__",
|
|
12
|
+
"SpanKind",
|
|
13
|
+
"Attr",
|
|
14
|
+
"Event",
|
|
15
|
+
"SPAN_KINDS",
|
|
16
|
+
"configure",
|
|
17
|
+
"force_flush",
|
|
18
|
+
"DebrixSpan",
|
|
19
|
+
"get_tracer",
|
|
20
|
+
"trace_agent",
|
|
21
|
+
"trace_tool",
|
|
22
|
+
"trace_span",
|
|
23
|
+
]
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""OTLP/HTTP exporter configuration for Debrix.
|
|
2
|
+
|
|
3
|
+
Default endpoint: ``http://127.0.0.1:4318`` (OTLP/HTTP protobuf).
|
|
4
|
+
Standard OpenTelemetry environment variables still apply and override defaults
|
|
5
|
+
when set (e.g. ``OTEL_EXPORTER_OTLP_ENDPOINT``).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import os
|
|
12
|
+
import warnings
|
|
13
|
+
from typing import Final
|
|
14
|
+
|
|
15
|
+
from opentelemetry import trace
|
|
16
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
17
|
+
from opentelemetry.sdk.resources import Resource
|
|
18
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
19
|
+
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SimpleSpanProcessor
|
|
20
|
+
|
|
21
|
+
from debrix.payloads import ensure_worker, flush_payloads, get_capture_mode
|
|
22
|
+
|
|
23
|
+
DEFAULT_OTLP_ENDPOINT: Final = "http://127.0.0.1:4318"
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger("debrix.config")
|
|
26
|
+
|
|
27
|
+
_configured = False
|
|
28
|
+
_endpoint: str = DEFAULT_OTLP_ENDPOINT
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _resolved_endpoint(endpoint: str | None = None) -> str:
|
|
32
|
+
if endpoint:
|
|
33
|
+
return endpoint.rstrip("/")
|
|
34
|
+
return os.environ.get(
|
|
35
|
+
"OTEL_EXPORTER_OTLP_ENDPOINT", DEFAULT_OTLP_ENDPOINT
|
|
36
|
+
).rstrip("/")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def force_flush(timeout_millis: int = 10_000) -> bool:
|
|
40
|
+
"""Flush OTLP spans and pending conversation payload uploads.
|
|
41
|
+
|
|
42
|
+
Short-lived scripts must call this (or rely on atexit) before exit;
|
|
43
|
+
otherwise ``blob_ref`` may land in Debrix without the payload body.
|
|
44
|
+
"""
|
|
45
|
+
ok = True
|
|
46
|
+
provider = trace.get_tracer_provider()
|
|
47
|
+
if isinstance(provider, TracerProvider):
|
|
48
|
+
ok = bool(provider.force_flush(timeout_millis=timeout_millis)) and ok
|
|
49
|
+
ok = flush_payloads(timeout_millis=timeout_millis) and ok
|
|
50
|
+
return ok
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def configure(
|
|
54
|
+
*,
|
|
55
|
+
endpoint: str | None = None,
|
|
56
|
+
service_name: str = "debrix",
|
|
57
|
+
batch: bool = True,
|
|
58
|
+
) -> TracerProvider:
|
|
59
|
+
"""Configure a global TracerProvider that exports OTLP/HTTP to Debrix.
|
|
60
|
+
|
|
61
|
+
Idempotent: subsequent calls return the existing provider without
|
|
62
|
+
re-installing exporters.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
endpoint: OTLP base URL (paths like ``/v1/traces`` are appended by the
|
|
66
|
+
exporter). Defaults to ``http://127.0.0.1:4318``, or
|
|
67
|
+
``OTEL_EXPORTER_OTLP_ENDPOINT`` when set.
|
|
68
|
+
service_name: Value for ``service.name`` resource attribute.
|
|
69
|
+
batch: Use ``BatchSpanProcessor`` when True (default); otherwise
|
|
70
|
+
``SimpleSpanProcessor`` (useful for short-lived scripts).
|
|
71
|
+
"""
|
|
72
|
+
global _configured, _endpoint
|
|
73
|
+
|
|
74
|
+
current = trace.get_tracer_provider()
|
|
75
|
+
# OpenTelemetry forbids replacing an installed TracerProvider; reuse it.
|
|
76
|
+
if isinstance(current, TracerProvider):
|
|
77
|
+
_configured = True
|
|
78
|
+
ensure_worker(_endpoint)
|
|
79
|
+
return current
|
|
80
|
+
|
|
81
|
+
resolved = _resolved_endpoint(endpoint)
|
|
82
|
+
_endpoint = resolved
|
|
83
|
+
# Ensure env protocol matches our contract when unset.
|
|
84
|
+
os.environ.setdefault("OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf")
|
|
85
|
+
|
|
86
|
+
if not batch and get_capture_mode() == "full":
|
|
87
|
+
warnings.warn(
|
|
88
|
+
"debrix.configure(batch=False) with full message capture may block "
|
|
89
|
+
"the agent on span end while large exports flush; prefer batch=True "
|
|
90
|
+
"for long-running agents.",
|
|
91
|
+
UserWarning,
|
|
92
|
+
stacklevel=2,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
resource = Resource.create({"service.name": service_name})
|
|
96
|
+
provider = TracerProvider(resource=resource)
|
|
97
|
+
exporter = OTLPSpanExporter(endpoint=f"{resolved}/v1/traces")
|
|
98
|
+
processor = (
|
|
99
|
+
BatchSpanProcessor(exporter) if batch else SimpleSpanProcessor(exporter)
|
|
100
|
+
)
|
|
101
|
+
provider.add_span_processor(processor)
|
|
102
|
+
trace.set_tracer_provider(provider)
|
|
103
|
+
_configured = True
|
|
104
|
+
ensure_worker(resolved)
|
|
105
|
+
return provider
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def reset_for_tests() -> None:
|
|
109
|
+
"""Reset configuration flag (tests only)."""
|
|
110
|
+
global _configured, _endpoint
|
|
111
|
+
_configured = False
|
|
112
|
+
_endpoint = DEFAULT_OTLP_ENDPOINT
|
|
113
|
+
from debrix.payloads import reset_worker_for_tests
|
|
114
|
+
|
|
115
|
+
reset_worker_for_tests()
|