Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access log: add support for %UPSTREAM_CONNECTION_ID% #31920

Merged

Conversation

deveshkandpal1224
Copy link
Contributor

Add support to print %UPSTREAM_CONNECTION_ID% in access log. Currently, %CONNECTION_ID% is supported which prints downstream connection id in access log. Primary motivation for add this is to easily debug reuse of an existing connection while debugging communication between client -> server especially during draining of upstream envoy.

Commit Message: Add support for %UPSTREAM_CONNECTION_ID% in access log
Additional Description: Primary motivation for add this is to easily reason reuse of an existing connection while debugging communication between client -> server.
Risk Level: low
Testing: unit testing
Docs Changes: updated
Release Notes: updated

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@deveshkandpal1224 deveshkandpal1224 changed the title Devesh24/access log upstream cx access log: add support for %UPSTREAM_CONNECTION_ID% Jan 22, 2024
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@deveshkandpal1224
Copy link
Contributor Author

/retest

Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for you contributions. One comment is added.

[](const std::string&, absl::optional<size_t>) {
return std::make_unique<StreamInfoUInt64FormatterProvider>(
[](const StreamInfo::StreamInfo& stream_info) {
return stream_info.upstreamInfo()->upstreamConnectionId().value_or(0);
Copy link
Member

Choose a reason for hiding this comment

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

                    if (stream_info.upstreamInfo().has_value()) {
                      return stream_info.upstreamInfo()->upstreamConnectionId().value_or(0);
                    }
                    return 0;

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@@ -889,7 +889,11 @@ const StreamInfoFormatterProviderLookupTable& getKnownStreamInfoFormatterProvide
[](const std::string&, absl::optional<size_t>) {
return std::make_unique<StreamInfoUInt64FormatterProvider>(
[](const StreamInfo::StreamInfo& stream_info) {
return stream_info.upstreamInfo()->upstreamConnectionId().value_or(0);
unsigned long result = 0;
Copy link
Member

Choose a reason for hiding this comment

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

We rarely use the type name unsigned long, may be uint64_t would be better here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wbpcode - fixed. CI seems to be failing for an unrelated test and I can't seem to restart the test using /retest. Ran the same failing test locally and its succeeding, so i'm guessing its flaky ?


bazel test //test/extensions/filters/http/alternate_protocols_cache:filter_integration_test

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@deveshkandpal1224
Copy link
Contributor Author

/retest

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@deveshkandpal1224
Copy link
Contributor Author

/retest

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Comment on lines 682 to 686
.. _config_access_log_format_upstream_connection_id:

%UPSTREAM_CONNECTION_ID%
An identifier for the upstream connection.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for you in timely update 😄 . This LGTM overall. Please supplement more context about the new command in the docs. I think this description should almost same with the CONNECTION_ID except it's used to tell the upstream connection id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@wbpcode
Copy link
Member

wbpcode commented Jan 24, 2024

/wait

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@wbpcode wbpcode enabled auto-merge (squash) January 24, 2024 03:38
@wbpcode wbpcode merged commit 282ff3a into envoyproxy:main Jan 24, 2024
53 checks passed
@deveshkandpal1224 deveshkandpal1224 deleted the devesh24/access-log-upstream-cx-id branch January 25, 2024 00:25
mattklein123 pushed a commit that referenced this pull request Sep 8, 2024
…lows (#35950)

Additional Description: The following PR:
#31920, added support for
``%UPSTREAM_CONNECTION_ID`` substitution string for access logs.
However, it's only supported for HTTP flows. Adding support for UDP and
TCP tunneling
Risk Level: low
Testing: unit tests, integration tests
Docs Changes: none
Release Notes: none
Platform Specific Features: none

---------

Signed-off-by: Ohad Vano <ohadvano@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.

2 participants