bzp2010 commented on code in PR #12383:
URL: https://github.com/apache/apisix/pull/12383#discussion_r2221993953


##########
apisix/plugin.lua:
##########
@@ -808,18 +797,18 @@ do
 end
 
 
-function _M.init_worker()
+function _M.init_prometheus()
     local _, http_plugin_names, stream_plugin_names = get_plugin_names()
+    local enabled_in_http = core.table.array_find(http_plugin_names, 
"prometheus")
+    local enabled_in_stream = core.table.array_find(stream_plugin_names, 
"prometheus")
 
-    -- some plugins need to be initialized in init* phases
-    if is_http and core.table.array_find(http_plugin_names, "prometheus") then
-        local prometheus_enabled_in_stream =
-            core.table.array_find(stream_plugin_names, "prometheus")
-        
require("apisix.plugins.prometheus.exporter").http_init(prometheus_enabled_in_stream)
-    elseif not is_http and core.table.array_find(stream_plugin_names, 
"prometheus") then
-        require("apisix.plugins.prometheus.exporter").stream_init()
+    if is_http and (enabled_in_http or enabled_in_stream) then

Review Comment:
   ### NOTE
   
   We will always only handle metrics generation in the http subsystem.
   
   1. This will ensure that there is no duplication of execution on http and 
stream to waste compute resources.
   2. This simplifies the design.
   3. Whether or not the user has http enabled (i.e., whether or not it is in 
stream only mode), an http block for the Prometheus export API and its server 
block (`:9091`) will always be present, otherwise Prometheus would be 
pointless. This means that we can always have an http subsystem context for 
periodic generation of timers and metrics anyway, even if we are currently in 
stream only mode.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to