lua: add stats API for creating counters, gauges, and histograms#44334
Merged
wbpcode merged 5 commits intoenvoyproxy:mainfrom Apr 16, 2026
Merged
lua: add stats API for creating counters, gauges, and histograms#44334wbpcode merged 5 commits intoenvoyproxy:mainfrom
wbpcode merged 5 commits intoenvoyproxy:mainfrom
Conversation
18b7bed to
8dd7403
Compare
Member
Author
|
All the CI failures I'm seeing are pointing to the Rust SDK which should be unrelated to this PR so opening... hello Envoy friends :) 👋 |
8dd7403 to
cef13e4
Compare
wbpcode
reviewed
Apr 11, 2026
Member
wbpcode
left a comment
There was a problem hiding this comment.
Thanks for this great contribution. I guess this cannot catch up 1.38 but should be good to be part of 1.39.
Could you merge main to fix the CI also? Thanks.
| * @return Stats::ScopeSharedPtr the stats scope for creating custom Lua stats. The scope | ||
| * is pre-configured with the appropriate lua stat prefix. | ||
| */ | ||
| virtual Stats::ScopeSharedPtr statsScope() PURE; |
Member
There was a problem hiding this comment.
Suggested change
| virtual Stats::ScopeSharedPtr statsScope() PURE; | |
| virtual Stats::Scope& statsScope() PURE; |
Member
There was a problem hiding this comment.
we needn't to extend the lifetime of scope so reference is preferred..
09aeec5 to
3cb64a6
Compare
Member
Author
|
@wbpcode updated - sorry about the force-pushes, had to fix my DCO workflow. |
Member
Author
|
MacOS and |
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
9b3530c to
758ad2e
Compare
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
Member
|
The release of 1.38 is delayed and this change is low risk change. |
Member
Author
|
Thanks for squeezing this in @wbpcode! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
stats()method to the Lua stream handle that returns a stats scope object, allowing Lua scripts to create and manipulate Envoy stats directly. This has been a requested feature for a while - being able to emit custom metrics from Lua scripts without needing to write a native filter.The API provides:
counter(name)- create/get a counter withinc(),add(),value()methodsgauge(name)- create/get a gauge withinc(),dec(),add(),sub(),set(),value()methodshistogram(name, unit)- create/get a histogram withrecordValue()methodExample usage:
Stats are prefixed with
lua.plus the optionalstat_prefixfrom the filter config. Gauges useNeverImportmode since they track local process state and shouldn't be accumulated across hot restarts.Risk Level: low
Testing: unit tests & integration test
Docs Changes: done
Release Notes: done
Platform Specific Features: no