Repository navigation
envoy/tracing: Add method Envoy::Tracing::Span::updateParent() - #48250
Conversation
|
@paul-r-gall PTAL |
245e9a8 to
781ff87
Compare
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
d794b0e to
1961af0
Compare
mattklein123
left a comment
There was a problem hiding this comment.
Sorry but I'm a little lost on the purpose of this. If you enable tracing why wouldn't this always be the behavior? Wouldn't the default be to just proxy through without creating a parent span and this is what you get when you enable tracing?
/wait-any
1961af0 to
1e2e94c
Compare
Hey @mattklein123, sorry for the delay. For context, we already have a "passthrough" mode of MCP trace context propagation, where McpFilter just copies the request body's trace context into the headers. This mode is enabled when the Simple passthrough is fine when Envoy isn't going to generate a span, and it's necessary so the trace doesn't end at Envoy — after all, we want the upstream's spans to be hooked up to the request's trace context. However, when we want Envoy to generate a span, simple passthrough is not sufficient. MCP puts the traceparent in the body rather than headers, so by the time McpFilter processes the MCP request body, Envoy has already created a span without knowledge of the body's trace context! The workaround implemented by this stack of CLs is to mutate the active span, post-hoc, such that it's a child span of the body's traceparent. It also becomes necessary to rewrite the request body so the upstream's spans descend from the active span. This new behavior will be controlled by the boolean I hope that makes sense, and please let me know if you have more questions. CC @paul-r-gall. |
1e2e94c to
bbb3a00
Compare
Correction: the simple passthrough mode is currently broken when the OpenTelemetry tracer is also configured. I believe the issue is that envoy/source/extensions/tracers/opentelemetry/tracer.cc Lines 120 to 123 in a071a0b |
bbb3a00 to
e5c04dd
Compare
mattklein123
left a comment
There was a problem hiding this comment.
OK thanks this makes sense. I didn't understand the trace in body part.
e5c04dd to
78ff718
Compare
60aec91 to
d8bf297
Compare
| * Reparent this span based on the given trace context. | ||
| */ | ||
| virtual void updateParent([[maybe_unused]] const TraceContext& context, | ||
| [[maybe_unused]] bool preserve_headers) {} |
There was a problem hiding this comment.
@paul-r-gall, @mattklein123, @botengyao: Any opinion this bool preserve_headers parameter?
I need some way to prevent the OpenTelemetry Span::injectContext() from overwriting headers when the McpFilter's trace context propagation mode is COPY or COPY_AND_REPARENT_SPAN. (We only want to rewrite the body/headers when the mode is REWRITE_AND_REPARENT_SPAN.)
d8bf297 to
88043f5
Compare
…48249) <!-- !!!ATTENTION!!! If you are fixing **any** crash or **any** potential security issue, **do not open a pull request**. Instead, please [open a GitHub Security Advisory](https://github.com/envoyproxy/envoy/security/advisories/new) (preferred). Alternatively, you may email [email protected]. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) !!!ATTENTION!!! Please check the [use of generative AI policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41). You may use generative AI only if you fully understand the code. You need to disclose this usage in the PR description to ensure transparency. --> Commit Message: Additional Description: This is the first PR in a chain, with the high-level goal of getting McpFilter to reparent the active span based on the request body's trace context. For reference, here is the full PR chain: 1. #48249 1. #48250 1. #48449 1. #48448 1. #48516 1. #48038 1. #48450 1. #48451 This PR was created with help from generative AI (Gemini). I fully understand the code. Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: dmcardle <[email protected]>
0879181 to
5c87940
Compare
Signed-off-by: dmcardle <[email protected]>
5c87940 to
a3a3157
Compare
|
/retest |
|
@botengyao or @paul-r-gall, please merge when you get a chance :) |
…Extractor (#48449) <!-- !!!ATTENTION!!! If you are fixing **any** crash or **any** potential security issue, **do not open a pull request**. Instead, please [open a GitHub Security Advisory](https://github.com/envoyproxy/envoy/security/advisories/new) (preferred). Alternatively, you may email [email protected]. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) !!!ATTENTION!!! Please check the [use of generative AI policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41). You may use generative AI only if you fully understand the code. You need to disclose this usage in the PR description to ensure transparency. --> Commit Message: opentelemetry: Add traceparent parse/serialize methods to SpanContextExtractor This new override will be used by McpFilter in PR #48038. Additional Description: This PR was created with help from generative AI (Gemini). I fully understand the code. For reference, here is the full PR chain: 1. #48249 1. #48250 1. #48449 1. #48448 1. #48516 1. #48038 1. #48450 1. #48451 Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: dmcardle <[email protected]>
This new override will be used by McpFilter in PR #48038. Additional Description: This PR was created with help from generative AI (Gemini). I fully understand the code. For reference, here is the full PR chain: 1. #48249 1. #48250 1. #48449 1. #48448 1. #48516 1. #48038 1. #48450 1. #48451 Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] --------- Signed-off-by: dmcardle <[email protected]>
This commit deduplicates constants related to W3C traceparent into source/common/tracing/tracing_validation.h. Additional Description: This PR was created with help from generative AI (Gemini). I fully understand the code. For reference, here is the full PR chain: 1. #48249 1. #48250 1. #48449 1. #48448 1. #48516 1. #48038 1. #48450 1. #48451 Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: dmcardle <[email protected]>
Commit Message:
Additional Description: This change supports #48038
This PR was created with help from generative AI (Gemini). I fully understand the code.
For reference, here is the full PR chain:
modefield to TraceContextPropagationConfig in mcp.proto #48249resample_on_update_parentto OpenTelemetryConfig #48450Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]