You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/07/07 02:08:57 UTC

[GitHub] [shardingsphere] jiangML commented on a diff in pull request #18907: Fixed the error of null value in contextManager when collecting metric data

jiangML commented on code in PR #18907:
URL: https://github.com/apache/shardingsphere/pull/18907#discussion_r915386512


##########
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollector.java:
##########
@@ -56,10 +56,10 @@ public List<MetricFamilySamples> collect() {
             return Collections.emptyList();
         }
         Optional<GaugeMetricFamily> proxyInfo = FACTORY.createGaugeMetricFamily(MetricIds.PROXY_INFO);
-        Optional<StateContext> stateContext = ProxyContext.getInstance().getStateContext();
-        if (!proxyInfo.isPresent() || !stateContext.isPresent()) {
+        if (null == ProxyContext.getInstance().getContextManager() || !proxyInfo.isPresent()) {

Review Comment:
   I thought that when the ContextManager is not empty, the stateContext will definitely not be empty.
   According to ProxyContext to obtain the internal logic of stateContext, judgment should be added.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org