Commit 7f188ef
authored
feat(observability): propagate W3C trace context across nico-api's network boundaries (#2700)
Implements W3C Trace Context propagation for nico-api so a request
traced upstream keeps one trace as
it passes through nico-api and into the services it calls.
- **Propagator:** install the standard W3C `TraceContextPropagator` at
startup (the OTel default is no-op).
- **Ingress (REST + gRPC):** one shared per-request layer extracts the
inbound `traceparent`/`tracestate`
and parents the request span to it; no valid inbound context → fresh
root.
- **Egress:** gRPC clients are wrapped in a tower `TraceInjectService`;
reqwest clients go through
`reqwest-tracing`'s middleware; the two OAuth2 token providers inject
manually (the `oauth2` crate
builds their requests).
- **Enable flag unchanged:** the local `tracing-enabled` switch stays
the master control — an inbound
`sampled` flag can't force local recording.
Per-client details and how to add a new client are in
`docs/observability/tracing.md`.
## Related issues
#2438
## Type of Change
- [x] **Add** - New feature or capability
- [ ] **Change** - Changes in existing functionality
- [ ] **Fix** - Bug fixes
- [ ] **Remove** - Removed features or deprecated functionality
- [ ] **Internal** - Internal changes (refactoring, tests, docs, etc.)
## Breaking Changes
- [ ] **This PR contains breaking changes**
## Testing
- [x] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)
## Additional Notes
- **Scope is the nico-api process.** `bmc-proxy` and `hardware-health`
are intentionally **not** instrumented:
they build no span exporter, so injecting there would be dead code.
`docs/observability/tracing.md` §1.7
documents how to add propagation to a new client if that changes.
- New crate `trace-propagation` holds the shared glue + tower
middleware.
- **`tracing.md` marker references are a doc-staleness fix, not part of
this feature.** The doc still
described the sampler's old `code.namespace` marker; #2268 replaced it
with `carbide.trace_root`
without updating the doc. The `code.namespace`→`carbide.trace_root` doc
edits just correct that.
(The doc's `ParentBased` mention is also updated, since this PR unwraps
the sampler.)
- Dependencies added: `opentelemetry-http` 0.31, `reqwest-middleware`
0.5, `reqwest-tracing` 0.7.
---------
Signed-off-by: Adnan Dosani <258082943+adnandnv@users.noreply.github.com>
Co-authored-by: Adnan Dosani <258082943+adnandnv@users.noreply.github.com>1 parent 9383cc7 commit 7f188ef
33 files changed
Lines changed: 1007 additions & 76 deletions
File tree
- crates
- api-core
- src
- handlers
- logging
- machine_identity
- api-web
- src
- component-manager
- src
- firmware
- src
- libmlx
- src/firmware
- libnmxc
- src
- libnmxm
- src
- mqttea
- src/auth
- nras
- src
- rpc
- src
- trace-propagation
- src
- tests
- docs/observability
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
462 | 467 | | |
463 | 468 | | |
464 | 469 | | |
| |||
558 | 563 | | |
559 | 564 | | |
560 | 565 | | |
561 | | - | |
562 | | - | |
| 566 | + | |
| 567 | + | |
563 | 568 | | |
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
568 | | - | |
569 | | - | |
| 573 | + | |
| 574 | + | |
570 | 575 | | |
571 | 576 | | |
572 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
166 | 173 | | |
167 | 174 | | |
168 | 175 | | |
| |||
0 commit comments