spacewander commented on a change in pull request #3070:
URL: https://github.com/apache/apisix/pull/3070#discussion_r545098278
##########
File path: apisix/plugins/prometheus/exporter.lua
##########
@@ -45,10 +45,10 @@ local DEFAULT_BUCKETS = { 1, 2, 5, 7, 10, 15, 20, 25, 30,
40, 50, 60, 70,
local metrics = {}
- local inner_tab_arr = {}
-local function gen_arr(...)
- clear_tab(inner_tab_arr)
+local function gen_arr(...)
Review comment:
We don't need this if we can't share the table.
##########
File path: apisix/utils/batch-processor.lua
##########
@@ -146,8 +150,19 @@ function batch_processor:push(entry)
return
end
+ if not batch_metrics and prometheus.get_prometheus() and self.name
+ and self.route_id and self.server_addr then
+ batch_metrics =
prometheus.get_prometheus():gauge("batch_process_entries",
+ "batch process
remaining entries",
+ {"name", "route_id",
"server_addr"})
+ end
+
local entries = self.entry_buffer.entries
table.insert(entries, entry)
+ -- add batch metric for every route
+ if batch_metrics then
+ batch_metrics:set(#entries, prometheus.gen_arr(self.name,
self.route_id, self.server_addr))
Review comment:
We can store the table: `self.xxx = {self.name, self.route_id,
self.server_addr}`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]