Skip to content

Support Gauge in Stats AccessLogger#42226

Merged
wbpcode merged 52 commits intoenvoyproxy:mainfrom
TAOXUY:gauge
Feb 12, 2026
Merged

Support Gauge in Stats AccessLogger#42226
wbpcode merged 52 commits intoenvoyproxy:mainfrom
TAOXUY:gauge

Conversation

@TAOXUY
Copy link
Copy Markdown
Contributor

@TAOXUY TAOXUY commented Nov 24, 2025

Description
This PR adds support for Gauges in the Stats AccessLogger.

Changes
Gauge Operations: Added support for three operations: SET, PAIRED_ADD, and PAIRED_SUBTRACT.

Configuration: Updated the stats.proto to include the new Gauge configuration options.

Risk Level
Low. The changes are focused on extending the Stats AccessLogger functionality and include specific handling to maintain backward compatibility for existing counter/histogram eviction logic.

Testing
Unit Tests: Added to verify the new gauge operations and eviction logic.

Integration Tests: Added to ensure end-to-end functionality within the access logging pipeline.

Documentation & Release Notes
Docs: Updated Protobuf comments to reflect new operations and memory overhead considerations.

Release Notes: Updated to include this new feature.

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

🐱

Caused by: #42226 was opened by TAOXUY.

see: more, trace.

@TAOXUY TAOXUY changed the title AccessLogger: support Gauge in access_loggers.stats Support Gauge in access_loggers.stats Nov 24, 2025
@TAOXUY
Copy link
Copy Markdown
Contributor Author

TAOXUY commented Nov 24, 2025

@kyessenov

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

/wait

Comment thread api/envoy/extensions/access_loggers/stats/v3/stats.proto Outdated
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait

Comment thread api/envoy/extensions/access_loggers/stats/v3/stats.proto Outdated
Comment thread changelogs/current.yaml Outdated
Comment thread api/envoy/extensions/access_loggers/stats/v3/stats.proto Outdated
@TAOXUY TAOXUY changed the title Support Gauge in access_loggers.stats [WIP]Support Gauge in access_loggers.stats Dec 8, 2025
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@TAOXUY TAOXUY changed the title [WIP]Support Gauge in access_loggers.stats Support Gauge in access_loggers.stats Dec 22, 2025
@TAOXUY TAOXUY changed the title Support Gauge in access_loggers.stats Support Gauge in Stats AccessLogger Dec 22, 2025
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@mattklein123 mattklein123 removed their assignment Dec 31, 2025
@TAOXUY
Copy link
Copy Markdown
Contributor Author

TAOXUY commented Feb 11, 2026

All comments are resolved. PTAL

Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Comment thread source/extensions/access_loggers/stats/stats.cc
Comment thread test/extensions/access_loggers/stats/stats_test.cc
Comment thread source/extensions/access_loggers/stats/stats.cc
shane-yuan pushed a commit to shane-yuan/envoy that referenced this pull request Feb 11, 2026
Change-Id: Ib8485b0d970f05dc9e4f93b01f8dfd81c54662dd

Commit Message: Add ability to log connection starts in TCP proxy. This
coupled with envoyproxy#42226 should
provide "almost" exact active connection gauge. (The problematic edge
case is when a prior filter stops iteration in `onNewConnection` or a
disconnect happens prior to reaching `tcp_proxy` - that requires unusual
config).
Risk Level: low
Testing: added
Docs Changes: yes
Release Notes: yes

---------

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@TAOXUY
Copy link
Copy Markdown
Contributor Author

TAOXUY commented Feb 11, 2026

All comments are resolved. PTAL

Stats::Gauge::ImportMode) -> Stats::Gauge& {
EXPECT_TRUE(tags.has_value());
if (tags) {
EXPECT_EQ(tags->get().size(), saved_tags.size());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please check that both the name, and the values of the tags, are identical. They need to be in the same order. If any of the parameters are different, you'll get a different stat, and that means this code didn't work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DONE.

Comment thread envoy/stats/scope.h Outdated

private:
absl::flat_hash_set<Stats::Gauge*> inflight_gauges_;
absl::flat_hash_map<Stats::Gauge*, uint64_t> inflight_gauges_;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Though refcount can help with gauge liveness, we don't want eviction as we want the previous value be kept.

// stat sinks by sending too many unique metrics.

//
// It is required to use a delta stat sink (e.g. OpenTelemetry) because this
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Allow ScopeStatsLimitSettings make sense

Let's make the default as: delta counter/histogram and accumulated gauge

And we can extend in the following PR to support : accumulated counter/histogram

I will add TODO and update the comment if that sounds good to u.

// iv). If the PAIRED_ADD operation was executed, the
// PAIRED_SUBTRACT will happen when the stream/connection is closed, even
// if the configured log type didn't happen.
enum OperationType {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am fine with either. One thing is maybe PAIRED_ADD and PAIRD_SUBTRACT is more open to be evolved to support non-paired one.

@wbpcode WDYT?

// iv). If the PAIRED_ADD operation was executed, the
// PAIRED_SUBTRACT will happen when the stream/connection is closed, even
// if the configured log type didn't happen.
enum OperationType {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DONE.

void initialize(const envoy::extensions::access_loggers::stats::v3::Config& config) {
// The gauge is a member of store_, so we need to increment the ref count to prevent it from
// being deleted when the shared_ptr in AccessLogState is destroyed.
store_.gauge_.incRefCount();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DONE

Comment thread test/extensions/access_loggers/stats/stats_test.cc Outdated
Comment thread source/extensions/access_loggers/stats/stats.cc
Comment thread test/extensions/access_loggers/stats/stats_test.cc
Comment thread source/extensions/access_loggers/stats/stats.cc
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@TAOXUY
Copy link
Copy Markdown
Contributor Author

TAOXUY commented Feb 11, 2026

@ggreenway all comments are resolved

@TAOXUY
Copy link
Copy Markdown
Contributor Author

TAOXUY commented Feb 11, 2026

/retest

Signed-off-by: Xuyang Tao <taoxuy@google.com>
@ggreenway
Copy link
Copy Markdown
Member

@wbpcode can you do a final API signoff?

Comment on lines +117 to +124
message PairedAddSubtract {
// The access log type to trigger the add operation.
data.accesslog.v3.AccessLogType add_log_type = 1
[(validate.rules).enum = {defined_only: true}];

// The access log type to trigger the subtract operation.
data.accesslog.v3.AccessLogType sub_log_type = 2
[(validate.rules).enum = {defined_only: true}];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is that possible in the future that multiple log type will map to single operation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is feasible.

For Gauge PairedAddSubtract, you can still defined multiple gauges with the same config except log type pairs.

@wbpcode wbpcode dismissed mattklein123’s stale review February 12, 2026 02:37

Dismiss request change from Matt because the context is out of time.

@wbpcode wbpcode merged commit 7d05933 into envoyproxy:main Feb 12, 2026
28 checks passed
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
**Description**
This PR adds support for Gauges in the Stats AccessLogger.

**Changes**
Gauge Operations: Added support for three operations: SET, PAIRED_ADD,
and PAIRED_SUBTRACT.

Configuration: Updated the
[stats.proto](https://www.google.com/search?q=https://github.com/envoyproxy/envoy/pull/42226/files%23diff-4581f1e9c20a6e6259d646736480c54178308378619379854721789781878345)
to include the new Gauge configuration options.

**Risk Level**
Low. The changes are focused on extending the Stats AccessLogger
functionality and include specific handling to maintain backward
compatibility for existing counter/histogram eviction logic.

**Testing**
Unit Tests: Added to verify the new gauge operations and eviction logic.

Integration Tests: Added to ensure end-to-end functionality within the
access logging pipeline.

**Documentation & Release Notes**
Docs: Updated Protobuf comments to reflect new operations and memory
overhead considerations.

**Release Notes**: Updated to include this new feature.

---------

Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: nick <nickshokri@google.com>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
**Description**
This PR adds support for Gauges in the Stats AccessLogger.

**Changes**
Gauge Operations: Added support for three operations: SET, PAIRED_ADD,
and PAIRED_SUBTRACT.

Configuration: Updated the
[stats.proto](https://www.google.com/search?q=https://github.com/envoyproxy/envoy/pull/42226/files%23diff-4581f1e9c20a6e6259d646736480c54178308378619379854721789781878345)
to include the new Gauge configuration options.

**Risk Level**
Low. The changes are focused on extending the Stats AccessLogger
functionality and include specific handling to maintain backward
compatibility for existing counter/histogram eviction logic.

**Testing**
Unit Tests: Added to verify the new gauge operations and eviction logic.

Integration Tests: Added to ensure end-to-end functionality within the
access logging pipeline.

**Documentation & Release Notes**
Docs: Updated Protobuf comments to reflect new operations and memory
overhead considerations.

**Release Notes**: Updated to include this new feature.

---------

Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: nick <nickshokri@google.com>
grnmeira pushed a commit to grnmeira/envoy that referenced this pull request Mar 20, 2026
Change-Id: Ib8485b0d970f05dc9e4f93b01f8dfd81c54662dd

Commit Message: Add ability to log connection starts in TCP proxy. This
coupled with envoyproxy#42226 should
provide "almost" exact active connection gauge. (The problematic edge
case is when a prior filter stops iteration in `onNewConnection` or a
disconnect happens prior to reaching `tcp_proxy` - that requires unusual
config).
Risk Level: low
Testing: added
Docs Changes: yes
Release Notes: yes

---------

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Gustavo <grnmeira@gmail.com>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
**Description**
This PR adds support for Gauges in the Stats AccessLogger. 

**Changes**
Gauge Operations: Added support for three operations: SET, PAIRED_ADD,
and PAIRED_SUBTRACT.

Configuration: Updated the
[stats.proto](https://www.google.com/search?q=https://github.com/envoyproxy/envoy/pull/42226/files%23diff-4581f1e9c20a6e6259d646736480c54178308378619379854721789781878345)
to include the new Gauge configuration options.

**Risk Level**
Low. The changes are focused on extending the Stats AccessLogger
functionality and include specific handling to maintain backward
compatibility for existing counter/histogram eviction logic.

**Testing**
Unit Tests: Added to verify the new gauge operations and eviction logic.

Integration Tests: Added to ensure end-to-end functionality within the
access logging pipeline.

**Documentation & Release Notes**
Docs: Updated Protobuf comments to reflect new operations and memory
overhead considerations.

**Release Notes**: Updated to include this new feature.

---------

Signed-off-by: Xuyang Tao <taoxuy@google.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
**Description**
This PR adds support for Gauges in the Stats AccessLogger. 

**Changes**
Gauge Operations: Added support for three operations: SET, PAIRED_ADD,
and PAIRED_SUBTRACT.

Configuration: Updated the
[stats.proto](https://www.google.com/search?q=https://github.com/envoyproxy/envoy/pull/42226/files%23diff-4581f1e9c20a6e6259d646736480c54178308378619379854721789781878345)
to include the new Gauge configuration options.

**Risk Level**
Low. The changes are focused on extending the Stats AccessLogger
functionality and include specific handling to maintain backward
compatibility for existing counter/histogram eviction logic.

**Testing**
Unit Tests: Added to verify the new gauge operations and eviction logic.

Integration Tests: Added to ensure end-to-end functionality within the
access logging pipeline.

**Documentation & Release Notes**
Docs: Updated Protobuf comments to reflect new operations and memory
overhead considerations.

**Release Notes**: Updated to include this new feature.

---------

Signed-off-by: Xuyang Tao <taoxuy@google.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.

5 participants