Skip to content

tracing: add new ability to customize span operation with formatter#42303

Merged
wbpcode merged 18 commits intoenvoyproxy:mainfrom
wbpcode:dev-span-operation
Dec 12, 2025
Merged

tracing: add new ability to customize span operation with formatter#42303
wbpcode merged 18 commits intoenvoyproxy:mainfrom
wbpcode:dev-span-operation

Conversation

@wbpcode
Copy link
Copy Markdown
Member

@wbpcode wbpcode commented Nov 29, 2025

Commit Message: tracing: add new ability to customize span operation with formatter
Additional Description:

To close #42288

Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

@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 @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #42303 was opened by wbpcode.

see: more, trace.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Nov 29, 2025

cc @zirain

Signed-off-by: wbpcode <wbphub@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Nov 30, 2025

/retest

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 1, 2025

/retest

}

EXPECT_CALL(config, modifySpan(_)).WillOnce(Invoke([this](Span& span) {
EXPECT_CALL(config, modifySpan(_, _)).WillOnce(Invoke([this](Span& span, bool) {
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.

FYI (no need for a change here but you can if you want), when doing an EXPECT_CALL with all the args wildcarded, you can just do

EXPECT_CALL(config, modifySpan)

instead of

EXPECT_CALL(config, modifySpan(_, _))

which can sometimes make this sort of update require fewer touches. In this case it wouldn't help much because the action invokes a function anyway so you'd have to change the args there, but still, slightly less fragile.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I never learned this before. Good suggestion.

Comment thread test/mocks/router/mocks.cc Outdated
Comment on lines +153 to +156
if (operation_ != nullptr) {
return makeOptRef<const Formatter::Formatter>(*operation_);
}
return OptRef<const Formatter::Formatter>();
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.

I think this block (and same for upstreamOperation below) could just be return makeOptRefFromPtr(operation_.get());

Comment thread tools/code_format/config.yaml Outdated
- source/common/event/file_event_impl.cc
- source/common/http/async_client_impl.cc
- source/common/grpc/google_async_client_impl.cc
- source/common/tracing/tracer_config_impl.h
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.

Could you move the implementation of the ConnectionManagerTracingConfig constructor into a cc file so that this exception is legitimate here? (Also because it's grown to be a pretty big constructor to be implemented in a header file.)
Otherwise the exception should be in the block above labeled

    # Header files that can throw exceptions. These should be limited; the only
    # valid situation identified so far is template functions used for config
    # processing.

(Even better would be to do the StatusOr thing and the validation in the function that calls the constructor and transform it to an exception a little bit further up the callstack where things are already thrown, so that a new exception isn't needed.)

@wbpcode wbpcode assigned adisuissa and unassigned markdroth Dec 5, 2025
Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: wbpcode <wbphub@gmail.com>
ravenblackx
ravenblackx previously approved these changes Dec 8, 2025
Signed-off-by: code <wbphub@gmail.com>
@zirain
Copy link
Copy Markdown
Member

zirain commented Dec 10, 2025

/retest

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 10, 2025

/retest

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 10, 2025

gently ping @adisuissa for an API review.

ravenblackx
ravenblackx previously approved these changes Dec 10, 2025
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks!
Overall API lgtm. Left some minor comments

enum OperationName {
// The HTTP listener is used for ingress/incoming requests.
INGRESS = 0;
INGRESS = 0 [deprecated = true, (envoy.annotations.deprecated_at_minor_version_enum) = "3.0"];
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.

These changes are not needed. If there was a field using the enum, it should've been deprecated. The not-implemented-hide is sufficient.

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.

Coming to think about it again, if this enum isn't used anywhere, what will be the implications of removing that completely?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Coming to think about it again, if this enum isn't used anywhere, what will be the implications of removing that completely?

We rarely remove API and only mark it as un-implemented and deprecated to ensure it will not be used again. But, yeah, maybe not-implemented-hide is sufficient.

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.

I was also going to suggest removing it completely (since the field that used it has been removed completely), but the enum is still used in code. I think probably those usages should be cleaned up too, but that seems like a followup thing rather than something to include in this PR.

//
// The same :ref:`format specifier <config_access_log_format>` as used for
// :ref:`HTTP access logging <config_access_log>` applies here, however
// unknown specifier values are replaced with the empty string instead of ``-``.
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.

OOC why is there an edge case here with replacement value for unknown specifier?
If this is for backwards compatibility, SGTM.
However, if this is something that is added because the implementation is a bit different, then I think the argument of keeping a consistent replacement strategy may outweigh the implementation complexity cost. (the main reason is that if someone has a tool that looks at traces and looks for those "-" that are now an empty string, it makes their tools harder to maintain).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not a new behavior. Except the access log, in all other substitution formatters (header mutation, custom tag, and so on), unknown specifier values are replaced with the empty string instead of -. Even the comment self, I copied it from header mutation/custom tag. 🤣

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.

yeah, you have more context on formatter features than I do.

Comment thread api/envoy/config/route/v3/route_components.proto Outdated
Co-authored-by: Adi (Suissa) Peleg <adip@google.com>
Signed-off-by: code <wbphub@gmail.com>
wbpcode and others added 2 commits December 11, 2025 10:24
…3/http_connection_manager.proto

Co-authored-by: Adi (Suissa) Peleg <adip@google.com>
Signed-off-by: code <wbphub@gmail.com>
Signed-off-by: wbpcode <wbphub@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 11, 2025

/retesst

@ravenblackx
Copy link
Copy Markdown
Contributor

/retest

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

/lgtm api

//
// The same :ref:`format specifier <config_access_log_format>` as used for
// :ref:`HTTP access logging <config_access_log>` applies here, however
// unknown specifier values are replaced with the empty string instead of ``-``.
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.

yeah, you have more context on formatter features than I do.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 11, 2025

/retest

1 similar comment
@zirain
Copy link
Copy Markdown
Member

zirain commented Dec 12, 2025

/retest

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 12, 2025

/retest

@wbpcode wbpcode enabled auto-merge (squash) December 12, 2025 09:29
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Dec 12, 2025

friendly ping another approval cc @ravenblackx 🌷

@wbpcode wbpcode merged commit 9747733 into envoyproxy:main Dec 12, 2025
26 checks passed
@wbpcode wbpcode deleted the dev-span-operation branch December 12, 2025 16:44
MayorFaj pushed a commit to MayorFaj/envoy that referenced this pull request Dec 15, 2025
…nvoyproxy#42303)

Commit Message: tracing: add new ability to customize span operation
with formatter
Additional Description:

To close envoyproxy#42288

Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: code <wbphub@gmail.com>
Co-authored-by: Adi (Suissa) Peleg <adip@google.com>
Signed-off-by: MayorFaj <mayorfaj@gmail.com>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
…nvoyproxy#42303)

Commit Message: tracing: add new ability to customize span operation
with formatter
Additional Description:

To close envoyproxy#42288

Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: code <wbphub@gmail.com>
Co-authored-by: Adi (Suissa) Peleg <adip@google.com>
Signed-off-by: Gustavo <grnmeira@gmail.com>
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.

Better route decorator

5 participants