lua: add stats API for creating counters, gauges, and histograms#44334
Draft
derekargueta wants to merge 1 commit intoenvoyproxy:mainfrom
Draft
lua: add stats API for creating counters, gauges, and histograms#44334derekargueta wants to merge 1 commit intoenvoyproxy:mainfrom
derekargueta wants to merge 1 commit intoenvoyproxy:mainfrom
Conversation
83e821c to
18b7bed
Compare
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
18b7bed to
8dd7403
Compare
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.
Description
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
This is an additive API that doesn't change existing behavior.
Testing
Test Plan
//test/extensions/filters/http/lua:wrappers_test)//test/extensions/filters/http/lua:lua_filter_test)//test/extensions/filters/http/lua:lua_integration_test --test_filter="*StatsApi*")Documentation
Added docs for the new
stats()method and all stat object APIs tolua_filter.rst.Signed-off-by: Derek Argueta derek.argueta@airbnb.com