Skip to content

Commit 9ae6eba

Browse files
feat(agent-reach): add LoongSuite instrumentation for Agent-Reach
Implements OpenTelemetry instrumentation for the Agent-Reach framework (https://github.com/Panniantong/Agent-Reach) per the execute.md plan in llm-dev/agent-reach/investigate/. Coverage: - ENTRY span on agent_reach.cli.main - TOOL span on agent_reach.doctor.check_all - TOOL span on every Channel.check override (dynamic discovery via register_post_import_hook on agent_reach.channels) - TOOL span on agent_reach.probe.probe_command - TOOL span on agent_reach.transcribe.transcribe and transcribe_chunk - Conditional TOOL span on agent_reach.integrations.mcp_server.create_server (skipped when loongsuite-instrumentation-mcp is already active to avoid duplicate spans) Spans are produced via opentelemetry-util-genai's ExtendedTelemetryHandler (entry/execute_tool context managers). Sensitive content (gen_ai.tool.call.arguments / .result) is gated behind OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT plus the experimental semconv opt-in, matching the util-genai contract. Custom metrics (agent_reach_channel_status, agent_reach_probe_total, agent_reach_probe_duration_seconds) record channel health and probe outcomes; generic request/error/duration metrics are derived by the backend from span data. All 7 unit tests pass; ruff lint clean. Co-authored-by: multica-agent <github@multica.ai>
1 parent 01bba83 commit 9ae6eba

12 files changed

Lines changed: 1674 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# LoongSuite Agent-Reach Instrumentation
2+
3+
OpenTelemetry instrumentation for [Agent-Reach](https://github.com/Panniantong/Agent-Reach)
4+
(`pip install agent-reach`).
5+
6+
## Coverage
7+
8+
| Span | Operation | Patch point |
9+
|------|-----------|-------------|
10+
| ENTRY | `enter` | `agent_reach.cli.main` |
11+
| TOOL | `execute_tool` | `agent_reach.doctor.check_all` |
12+
| TOOL | `execute_tool` | every `Channel.check` override (dynamic discovery via `register_post_import_hook`) |
13+
| TOOL | `execute_tool` | `agent_reach.probe.probe_command` |
14+
| TOOL | `execute_tool` | `agent_reach.transcribe.transcribe` |
15+
| TOOL | `execute_tool` | `agent_reach.transcribe.transcribe_chunk` |
16+
| TOOL | `execute_tool` | `agent_reach.integrations.mcp_server.create_server` (only when `loongsuite-instrumentation-mcp` is NOT active) |
17+
18+
Span hierarchy:
19+
20+
```
21+
ENTRY (enter_ai_application_system)
22+
├─ TOOL (execute_tool doctor)
23+
│ ├─ TOOL (execute_tool channel-github)
24+
│ │ └─ TOOL (execute_tool probe-gh)
25+
│ ├─ TOOL (execute_tool channel-twitter)
26+
│ │ └─ TOOL (execute_tool probe-twitter)
27+
│ └─ … (remaining channels)
28+
├─ TOOL (execute_tool agent-reach-transcribe)
29+
│ └─ TOOL (execute_tool whisper-transcribe) × N
30+
└─ TOOL (execute_tool mcp-get_status) [conditional]
31+
```
32+
33+
Sensitive content (`gen_ai.tool.call.arguments` / `gen_ai.tool.call.result`)
34+
is gated behind `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT`. When
35+
the flag is unset / `NO_CONTENT`, only non-PII diagnostic attributes
36+
(`agent_reach.channel.status`, `agent_reach.probe.status`, etc.) are emitted.
37+
38+
## Usage
39+
40+
```python
41+
from opentelemetry.instrumentation.agent_reach import AgentReachInstrumentor
42+
43+
AgentReachInstrumentor().instrument()
44+
```
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "loongsuite-instrumentation-agent-reach"
7+
dynamic = ["version"]
8+
description = "LoongSuite Agent-Reach Instrumentation"
9+
readme = "README.md"
10+
license = "Apache-2.0"
11+
requires-python = ">=3.10"
12+
authors = [
13+
{ name = "Ziming Liu", email = "liuziming.lzm@alibaba-inc.com" },
14+
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
15+
]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: Apache Software License",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
]
26+
dependencies = [
27+
"opentelemetry-api ~= 1.37",
28+
"opentelemetry-instrumentation >= 0.58b0",
29+
"opentelemetry-semantic-conventions >= 0.58b0",
30+
"opentelemetry-util-genai",
31+
"wrapt >= 1.17.3, < 2.0.0",
32+
]
33+
34+
[project.optional-dependencies]
35+
instruments = [
36+
"agent-reach >= 1.5.0",
37+
]
38+
39+
test = [
40+
"pytest ~= 8.0",
41+
"pytest-asyncio ~= 0.23.0",
42+
"pytest-cov ~= 4.1.0",
43+
"agent-reach >= 1.5.0",
44+
]
45+
46+
[project.entry-points.opentelemetry_instrumentor]
47+
agent_reach = "opentelemetry.instrumentation.agent_reach:AgentReachInstrumentor"
48+
49+
[project.urls]
50+
Homepage = "https://github.com/alibaba/loongsuite-python-agent/tree/main/instrumentation-loongsuite/loongsuite-instrumentation-agent-reach"
51+
Repository = "https://github.com/alibaba/loongsuite-python-agent"
52+
53+
[tool.hatch.version]
54+
path = "src/opentelemetry/instrumentation/agent_reach/version.py"
55+
56+
[tool.hatch.build.targets.sdist]
57+
include = [
58+
"/src",
59+
"/tests",
60+
]
61+
62+
[tool.hatch.build.targets.wheel]
63+
packages = ["src/opentelemetry"]
64+
65+
[tool.pytest.ini_options]
66+
asyncio_mode = "auto"

0 commit comments

Comments
 (0)