Commit e0ba1a6
authored
[jaegermcp] Expose service names in search_traces trace summaries (#8339)
## Which problem is this PR solving?
When an agent calls `search_traces`, the response includes
`service_count` (an integer) but not the actual service names. The agent
knows a trace spans 5 services but has no idea which ones. To find out,
it must call `get_trace_topology` or `get_span_details` for every trace
individually, which defeats the purpose of a lightweight summary
endpoint.
The data is already computed internally. `buildTraceSummary` builds a
`services` map to derive `service_count`, then discards the map keys.
This has been the case since the function was introduced in #7858, where
the map was built but only `len(services)` was surfaced. Subsequent
changes (#7859, #7863, #7916, #8194) restructured the types and renamed
fields but never revisited the service data gap.
## Short description of the changes
- Added `Services []string` to `TraceSummary`, populated from the
existing `services` map
- Sorted alphabetically via `slices.Sort` for deterministic output
across calls
- Added multi-service test with three services in non-alphabetical
order, unique span IDs, and proper parent-child relationships to verify
sort correctness
- Updated existing summary tests to assert on the new field
- `ServiceCount` preserved for backward compatibility
## Use case
An agent investigating a latency spike searches for slow traces. The
summary now returns:
```json
{
"service_count": 3,
"services": ["api-gateway", "payment", "user-service"]
}
```
The agent can immediately see that the payment service is involved and
drill into that trace, instead of blindly fetching topology for every
result.
## How was this change tested?
- `go test ./cmd/jaeger/internal/extension/jaegermcp/...` - all passing
- `make lint` - 0 issues
- `make fmt` - clean
- `make test` - 3053 tests passing
## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/main/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully: `make lint test`
## AI Usage in this PR (choose one)
- [x] **Light**: AI provided minor assistance (formatting, simple
suggestions)
Signed-off-by: Roshan Singh <roshansingh7890@gmail.com>
Signed-off-by: Roshan <rosh.s568@gmail.com>1 parent 7cccec2 commit e0ba1a6
3 files changed
Lines changed: 53 additions & 8 deletions
File tree
- cmd/jaeger/internal/extension/jaegermcp/internal
- handlers
- types
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
238 | 245 | | |
239 | 246 | | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
243 | 250 | | |
| 251 | + | |
244 | 252 | | |
245 | 253 | | |
246 | 254 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
49 | 85 | | |
50 | 86 | | |
51 | 87 | | |
| |||
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
0 commit comments