Skip to content

opentelemetry: Add bool field resample_on_update_parent to OpenTelemetryConfig - #48450

Open
dmcardle wants to merge 7 commits into
envoyproxy:mainfrom
dmcardle:otel-sample-bit-config-field
Open

dmcardle wants to merge 7 commits into
envoyproxy:mainfrom
dmcardle:otel-sample-bit-config-field

Conversation

@dmcardle

@dmcardle dmcardle commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #48450 was opened by dmcardle.

see: more, trace.

@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch from f56ba62 to 8997c6b Compare October 19, 2026 22:44
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 3 times, most recently from 7cd39b6 to 433ec31 Compare October 21, 2026 20:29
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 2 times, most recently from 632feef to c7e4af5 Compare October 21, 2026 22:47
@dmcardle dmcardle changed the title opentelemetry: Add bool field span_update_parent_copies_sampled_bit to OpenTelemetryConfig opentelemetry: Add bool field resample_on_update_parent to OpenTelemetryConfig Oct 21, 2026
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch from c7e4af5 to d7e9bb3 Compare October 21, 2026 22:51
@dmcardle
dmcardle marked this pull request as ready for review October 21, 2026 22:51
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @paul-r-gall
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #48450 was ready_for_review by dmcardle.

see: more, trace.

@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 2 times, most recently from e5c04dd to fe23bc3 Compare October 23, 2026 22:56
@dmcardle

Copy link
Copy Markdown
Contributor Author

I just rebased on tip-of-tree and noticed some of my PRs were in a funny state (possibly from attempting to use gh stack earlier today?). They should all be in good shape now, though. Sorry for any confusion!

@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 3 times, most recently from e9f294d to 11a95b8 Compare October 28, 2026 14:06
botengyao pushed a commit that referenced this pull request Oct 29, 2026
…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]>
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch from 11a95b8 to 25f8e61 Compare October 29, 2026 18:59
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 5 times, most recently from ecf9c79 to 64de446 Compare November 2, 2026 17:59
botengyao pushed a commit that referenced this pull request Nov 3, 2026
<!--
!!!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]>
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch from 64de446 to a38ef0d Compare November 3, 2026 16:14
botengyao pushed a commit that referenced this pull request Nov 19, 2026
…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]>
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch 2 times, most recently from 2263348 to 39307b6 Compare November 24, 2026 17:43
yanavlasov pushed a commit that referenced this pull request Dec 1, 2026
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]>
@dmcardle
dmcardle force-pushed the otel-sample-bit-config-field branch from d454c14 to 1e631a5 Compare December 2, 2026 15:52
@github-actions
github-actions Bot requested a balanced review from Copilot December 2, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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_parent field 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

Comment on lines +1025 to +1029
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());
Comment on lines +110 to +111
void onContainerClose(int, size_t token_end) override {
if (capturing_meta_) {
Comment on lines +1098 to +1099
TraceContextLocator locator;
RETURN_IF_NOT_OK(locator.feedSlices(body.getRawSlices()));
Comment on lines +1115 to +1118
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()));
Comment on lines +1128 to +1129
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)});
yanavlasov pushed a commit that referenced this pull request Dec 2, 2026
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]>

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants