Skip to content

feat: add trace_id to log output for OTel correlation#728

Open
DaleSeo wants to merge 1 commit intomainfrom
AMS-439
Open

feat: add trace_id to log output for OTel correlation#728
DaleSeo wants to merge 1 commit intomainfrom
AMS-439

Conversation

@DaleSeo
Copy link
Copy Markdown
Member

@DaleSeo DaleSeo commented Apr 15, 2026

Closes #686

Add trace_id=<32-hex> prefix to all log lines emitted within an OpenTelemetry-traced span, so operators can correlate logs with distributed traces. This is done via a custom FormatEvent wrapper that reads OtelData::trace_id() from the span chain before delegating to the default format.

  • Before
❯ cargo run -p apollo-mcp-server -- ./examples/TheSpaceDevs/config.yaml
    Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 11.38s
     Running `target/debug/apollo-mcp-server ./examples/TheSpaceDevs/config.yaml`
2026-04-15T14:40:55.330847Z  INFO Apollo MCP Server v1.12.0 // (c) Apollo Graph, Inc. // Licensed under MIT
2026-04-15T14:40:55.362467Z  INFO load_tool: Tool SearchUpcomingLaunches loaded with a character count of 545. Estimated tokens: 136
2026-04-15T14:40:55.368403Z  INFO load_tool: Tool ExploreCelestialBodies loaded with a character count of 761. Estimated tokens: 190
2026-04-15T14:40:55.373605Z  INFO load_tool: Tool GetAstronautDetails loaded with a character count of 898. Estimated tokens: 224
2026-04-15T14:40:55.378868Z  INFO load_tool: Tool GetAstronautsCurrentlyInSpace loaded with a character count of 501. Estimated tokens: 125
2026-04-15T14:40:55.395239Z  INFO schema_index: Indexed 50 types in 16.00ms
2026-04-15T14:40:55.398053Z  INFO Starting MCP server in Streamable HTTP mode port=8000 address=127.0.0.1
  • After
❯ cargo run -p apollo-mcp-server -- ./examples/TheSpaceDevs/config.yaml
    Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.60s
     Running `target/debug/apollo-mcp-server ./examples/TheSpaceDevs/config.yaml`
2026-04-15T14:36:32.060271Z  INFO Apollo MCP Server v1.12.0 // (c) Apollo Graph, Inc. // Licensed under MIT
trace_id=1b6ec242d9c61d3a49ae3d9a4abee507 2026-04-15T14:36:32.091848Z  INFO load_tool: Tool SearchUpcomingLaunches loaded with a character count of 545. Estimated tokens: 136
trace_id=50be2921f0ea177ceb4787b665e35369 2026-04-15T14:36:32.097931Z  INFO load_tool: Tool ExploreCelestialBodies loaded with a character count of 761. Estimated tokens: 190
trace_id=c9946787e06327ea3e883d6ffd33403e 2026-04-15T14:36:32.103155Z  INFO load_tool: Tool GetAstronautDetails loaded with a character count of 898. Estimated tokens: 224
trace_id=c293d31e37e814c80666dfc6515df595 2026-04-15T14:36:32.109268Z  INFO load_tool: Tool GetAstronautsCurrentlyInSpace loaded with a character count of 501. Estimated tokens: 125
trace_id=91e024fb2410f71cc8042bda55161cae 2026-04-15T14:36:32.126110Z  INFO schema_index: Indexed 50 types in 16.41ms
2026-04-15T14:36:32.128898Z  INFO Starting MCP server in Streamable HTTP mode port=8000 address=127.0.0.1

@DaleSeo DaleSeo self-assigned this Apr 15, 2026
@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Apr 15, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 8dc72f4d940de5c241321b7d
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@DaleSeo DaleSeo marked this pull request as ready for review April 15, 2026 15:07
@DaleSeo DaleSeo requested a review from a team as a code owner April 15, 2026 15:07
@github-actions
Copy link
Copy Markdown
Contributor

Changeset file added - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add traceid to Apollo MCP Server logs for every transaction

1 participant