Repository navigation
Conversation
f56ba62 to
8997c6b
Compare
7cd39b6 to
433ec31
Compare
632feef to
c7e4af5
Compare
span_update_parent_copies_sampled_bit to OpenTelemetryConfigresample_on_update_parent to OpenTelemetryConfig
c7e4af5 to
d7e9bb3
Compare
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
e5c04dd to
fe23bc3
Compare
|
I just rebased on tip-of-tree and noticed some of my PRs were in a funny state (possibly from attempting to use |
e9f294d to
11a95b8
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]>
11a95b8 to
25f8e61
Compare
ecf9c79 to
64de446
Compare
<!-- !!!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 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: 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]>
64de446 to
a38ef0d
Compare
…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]>
2263348 to
39307b6
Compare
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]>
Signed-off-by: dmcardle <[email protected]>
Signed-off-by: dmcardle <[email protected]>
Signed-off-by: dmcardle <[email protected]>
Signed-off-by: dmcardle <[email protected]>
…metryConfig Signed-off-by: dmcardle <[email protected]>
Signed-off-by: dmcardle <[email protected]>
…ctionary Signed-off-by: dmcardle <[email protected]>
d454c14 to
1e631a5
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved rewrite bugs can produce invalid JSON, declare an incorrect Content-Length, and propagate tracing context inconsistent with the active span.
7 open issues
Rewrite only after span reparenting succeeds · New Avoid incorrect Content-Length when parsing ends before the body · New Track _meta container depth when locating its closing brace · New Honor the parser's duplicate-key policy when locating fields · New Decode traceparent before validating its length · New Propagate the active span's sampling flag in the body · New JSON-escape tracestate values before inserting or replacing · New
What changed in this PR
Extends MCP trace propagation with active-span reparenting and body rewriting, supporting the linked tracing PR chain.
Changes:
- Adds MCP reparenting and trace-context rewriting, with unit and integration tests.
- Adds the hidden
resample_on_update_parentfield ahead of implementation in #48451. - Centralizes W3C trace-context size constants.
| File | Description |
|---|---|
tools/spelling/spelling_dictionary.txt |
Adds tracing and buffer terminology. |
test/extensions/filters/http/mcp/mcp_json_parser_test.cc |
Tests trace-context rewriting across buffer slices. |
test/extensions/filters/http/mcp/mcp_filter_test.cc |
Tests propagation modes and span updates. |
test/extensions/filters/http/mcp/mcp_filter_integration_test.cc |
Adds OpenTelemetry propagation integration tests. |
test/extensions/filters/http/mcp/BUILD |
Adds integration-test dependencies. |
source/extensions/tracers/opentelemetry/span_context_extractor.cc |
Uses shared trace-context constants. |
source/extensions/tracers/opentelemetry/BUILD |
Adds shared tracing dependency. |
source/extensions/tracers/fluentd/fluentd_tracer_impl.cc |
Uses shared trace-context constants. |
source/extensions/tracers/fluentd/BUILD |
Adds shared tracing dependency. |
source/extensions/filters/http/mcp/mcp_json_parser.h |
Declares the body-rewriting interface. |
source/extensions/filters/http/mcp/mcp_json_parser.cc |
Locates and rewrites trace-context byte ranges. |
source/extensions/filters/http/mcp/mcp_filter.h |
Passes body data into parsing completion. |
source/extensions/filters/http/mcp/mcp_filter.cc |
Implements reparenting and body-rewrite modes. |
source/extensions/filters/http/mcp/BUILD |
Adds tracing and rewriting dependencies. |
source/extensions/filters/common/mcp/constants.h |
Adds trace-context field names. |
source/common/tracing/tracing_validation.h |
Defines shared W3C size constants. |
source/common/tracing/tracing_validation.cc |
Adopts shared constants. |
api/envoy/config/trace/v3/opentelemetry.proto |
Adds the hidden resampling configuration field. |
Review effort: Balanced
| if (update_parent && | ||
| meta_fields.contains(Filters::Common::Mcp::McpConstants::TRACEPARENT_FIELD) && | ||
| !new_parent_id.empty()) { | ||
| Tracing::HttpTraceContext trace_context(*headers); | ||
| active_span.updateParent(trace_context, /*preserve_headers=*/!rewrite_body_and_headers); |
| ENVOY_LOG_EVERY_POW_2(warn, "MCP filter failed to rewrite traceparent: {}", | ||
| status.ToString()); | ||
| } else { | ||
| headers->setContentLength(decoding_buffer->length()); |
| void onContainerClose(int, size_t token_end) override { | ||
| if (capturing_meta_) { |
| TraceContextLocator locator; | ||
| RETURN_IF_NOT_OK(locator.feedSlices(body.getRawSlices())); |
| std::array<char, Tracing::W3cTraceConstants::kTraceparentHeaderSize> traceparent; | ||
| if (tp_range.size() != traceparent.size()) { | ||
| return absl::InvalidArgumentError(absl::StrCat("Parsed traceparent of size ", tp_range.size(), | ||
| ", but expected ", traceparent.size())); |
| parsed->setSpanId(std::string(new_parent_id)); | ||
| new_traceparent = SpanContextExtractor::serializeTraceparent(*parsed); |
|
|
||
| if (!new_tracestate.empty()) { | ||
| if (ts_range.has_value()) { | ||
| edits.push_back({*ts_range, std::move(new_tracestate)}); |
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 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:]