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


##########
apisix/plugins/prometheus/exporter.lua:
##########
@@ -438,13 +467,7 @@ local function shared_dict_status()
 end
 
 
-local function collect(ctx, stream_only)
-    if not prometheus or not metrics then
-        core.log.error("prometheus: plugin is not initialized, please make 
sure ",
-                     " 'prometheus_metrics' shared dict is present in nginx 
template")
-        return 500, {message = "An unexpected error occurred"}
-    end
-
+local function collect(yieldable)

Review Comment:
   I suggest to perform the first capture and metrics generation at 
`init_worker`, it is synchronously blocking, which makes the metrics almost 
always available, otherwise we can't be sure when the metrics will be 
available, which can lead to some unexpected exception responses (HTTP 500).



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