Commit 3dd8436
fix(runner): framework-agnostic observability naming + MLflow trace IDs (#1283)
<!-- acp:session_id=session-7d8df959-1f85-4738-ba2b-f08569ce8f7b
source=#1283 last_action=2026-04-10T19:17:53Z retry_count=1 -->
## Summary
Follow-up to the merged MLflow observability work: **`main` landed the
integration before these two commits could ship.** This PR restores
them.
### 1. Framework-agnostic tracing names (Langfuse + MLflow)
- Turn trace / span name: **`claude_interaction` → `llm_interaction`**
- Langfuse tags: **`claude-code` → `runner:<RUNNER_TYPE>`** (from
`RUNNER_TYPE`)
- Session metrics span: **`Claude Code - Session Metrics` → `Session
Metrics`**
- Metrics source metadata: **`claude-code-metrics` →
`ambient-runner-metrics`**
- Module docs updated so observability is described as runner-wide, not
Claude-only.
**Migration:** Existing Langfuse dashboards, alerts, or saved views that
filter on the old trace name or tags need to be updated to the new
values.
### 2. MLflow-only: trace IDs for middleware and feedback
When **`OBSERVABILITY_BACKENDS=mlflow`** (no Langfuse turn), the runner
now:
- Exposes **`mlflow.get_active_trace_id()`** via
**`ObservabilityManager.get_current_trace_id()`**
- Syncs **`last_trace_id`** after **`start_turn`** so AG-UI trace
events, corrections, and **`/feedback`** resolution behave like the
Langfuse path.
## Testing
- `pytest` (runner): `test_observability`, `test_observability_metrics`,
`test_observability_mlflow_integration`, `test_privacy_masking` (101
tests in local run)
## Commits
- `refactor(runner): framework-agnostic observability naming (Gage
review)` (cherry-picked)
- `fix(runner): expose MLflow trace ids when Langfuse is off`
(cherry-picked)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Runner type is captured and included in observability metadata and
span attributes.
* **Changes**
* Turn traces renamed vendor‑neutrally to "llm_interaction".
* Session metrics span renamed to "Session Metrics" and source to
"ambient-runner-metrics".
* Middleware event name changed to "ambient:trace_id" and now reflects
Langfuse or MLflow trace id.
* **Bug Fixes**
* Improved trace correlation between Langfuse and MLflow when one
backend is inactive.
* **Documentation**
* README updated to document turn trace naming and runner type tagging.
* **Tests**
* Updated and added tests validating tagging, naming, and
MLflow/Langfuse trace behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Ambient Code Bot <bot@ambient-code.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 2389565 commit 3dd8436
File tree
9 files changed
+172
-63
lines changed- components/runners/ambient-runner
- ambient_runner
- middleware
- tests
9 files changed
+172
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| 50 | + | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
| |||
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
91 | 101 | | |
92 | 102 | | |
93 | 103 | | |
| |||
125 | 135 | | |
126 | 136 | | |
127 | 137 | | |
128 | | - | |
| 138 | + | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
| 144 | + | |
134 | 145 | | |
135 | 146 | | |
136 | 147 | | |
| |||
249 | 260 | | |
250 | 261 | | |
251 | 262 | | |
252 | | - | |
| 263 | + | |
253 | 264 | | |
254 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
255 | 269 | | |
256 | 270 | | |
257 | 271 | | |
| |||
Lines changed: 101 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| |||
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
68 | 86 | | |
69 | 87 | | |
70 | 88 | | |
| |||
80 | 98 | | |
81 | 99 | | |
82 | 100 | | |
83 | | - | |
| 101 | + | |
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
| |||
185 | 203 | | |
186 | 204 | | |
187 | 205 | | |
| 206 | + | |
188 | 207 | | |
189 | 208 | | |
190 | 209 | | |
| |||
261 | 280 | | |
262 | 281 | | |
263 | 282 | | |
264 | | - | |
| 283 | + | |
265 | 284 | | |
266 | 285 | | |
267 | 286 | | |
| |||
351 | 370 | | |
352 | 371 | | |
353 | 372 | | |
354 | | - | |
| 373 | + | |
355 | 374 | | |
356 | 375 | | |
357 | 376 | | |
| |||
421 | 440 | | |
422 | 441 | | |
423 | 442 | | |
424 | | - | |
| 443 | + | |
425 | 444 | | |
426 | 445 | | |
427 | | - | |
| 446 | + | |
428 | 447 | | |
429 | 448 | | |
430 | 449 | | |
| |||
445 | 464 | | |
446 | 465 | | |
447 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
448 | 487 | | |
449 | 488 | | |
450 | 489 | | |
451 | 490 | | |
452 | 491 | | |
453 | | - | |
| 492 | + | |
| 493 | + | |
454 | 494 | | |
455 | | - | |
456 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
457 | 507 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
463 | 512 | | |
464 | 513 | | |
465 | 514 | | |
466 | | - | |
| 515 | + | |
467 | 516 | | |
468 | | - | |
469 | | - | |
| 517 | + | |
| 518 | + | |
470 | 519 | | |
471 | 520 | | |
472 | 521 | | |
| |||
495 | 544 | | |
496 | 545 | | |
497 | 546 | | |
498 | | - | |
| 547 | + | |
499 | 548 | | |
500 | 549 | | |
501 | 550 | | |
| |||
871 | 920 | | |
872 | 921 | | |
873 | 922 | | |
874 | | - | |
| 923 | + | |
| 924 | + | |
875 | 925 | | |
876 | 926 | | |
877 | 927 | | |
| |||
883 | 933 | | |
884 | 934 | | |
885 | 935 | | |
886 | | - | |
| 936 | + | |
887 | 937 | | |
888 | 938 | | |
889 | 939 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
| 376 | + | |
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
| |||
0 commit comments