Skip to content

Commit b5f227a

Browse files
committed
lua: Added new executions counter to the Lua filter to track script execution count.
Signed-off-by: Anirban Nandi <[email protected]>
1 parent ca1200b commit b5f227a

File tree

6 files changed

+184
-2
lines changed

6 files changed

+184
-2
lines changed

changelogs/current.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,8 @@ new_features:
158158
Added QUIC protocol option :ref:`max_sessions_per_event_loop
159159
<envoy_v3_api_field_config.listener.v3.QuicProtocolOptions.max_sessions_per_event_loop>` to limit the maximum
160160
number of new QUIC sessions created per event loop. The default is 16, preserving the previous hardcoded limit.
161+
- area: lua
162+
change: |
163+
Added new executions counter to the Lua filter to track script execution count.
161164
162165
deprecated:

docs/root/configuration/http/http_filters/lua_filter.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ individual filter instance/script can be tracked by providing a per-filter
137137
:header: Name, Type, Description
138138
:widths: 1, 1, 2
139139

140-
error, Counter, Total script execution errors.
140+
errors, Counter, Total script execution errors.
141+
executions, Counter, Total number of times ``envoy_on_request`` and ``envoy_on_response`` was executed.
141142

142143
Script examples
143144
---------------

source/extensions/filters/http/lua/lua_filter.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,10 @@ Filter::doHeaders(StreamHandleRef& handle, Filters::Common::Lua::CoroutinePtr& c
891891

892892
Http::FilterHeadersStatus status = Http::FilterHeadersStatus::Continue;
893893
TRY_NEEDS_AUDIT {
894+
// The counter will increment twice if the supplied script has both request and response
895+
// handles. This is intentionally kept so as to provide consistency with the way the 'errors'
896+
// counter is incremented.
897+
stats_.executions_.inc();
894898
status = handle.get()->start(function_ref);
895899
handle.markDead();
896900
}

source/extensions/filters/http/lua/lua_filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Lua {
2020
/**
2121
* All lua stats. @see stats_macros.h
2222
*/
23-
#define ALL_LUA_FILTER_STATS(COUNTER) COUNTER(errors)
23+
#define ALL_LUA_FILTER_STATS(COUNTER) COUNTER(errors) COUNTER(executions)
2424

2525
/**
2626
* Struct definition for all Lua stats. @see stats_macros.h

0 commit comments

Comments
 (0)