亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將應用程序遷移到 Spring boot 2 后無法向 /actuator/prometheus

將應用程序遷移到 Spring boot 2 后無法向 /actuator/prometheus

眼眸繁星 2023-07-19 10:27:34
將我的應用程序(stack spring boot、camel、hystrix)從 Spring Boot 1.5 遷移到 Spring Boot 2 后。我無法讓 hystrix 指標顯示在 /actuator/prometheus 中。正如許多解決方案和教程所建議的那樣,我已確保具有以下依賴項<dependency>   <groupId>io.micrometer</groupId>   <artifactId>micrometer-registry-prometheus</artifactId>   <version>${micrometer-version}</version></dependency><dependency>   <groupId>io.micrometer</groupId>   <artifactId>micrometer-core</artifactId>   <version>${micrometer-version}</version></dependency>并添加了以下配置類,我確信它正在被實例化,因為我已經在 Spring Boot 自動配置日志中檢查過:import io.micrometer.core.instrument.binder.hystrix.HystrixMetricsBinder;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class HystrixMetricsConfig {   @Bean   HystrixMetricsBinder registerHystrixMetricsBinder() {      return new HystrixMetricsBinder();   }}為了避免假設此類教程/答案的定義是正確的,我從頭開始設置了一個簡單的 Spring Boot 項目,其中包含一個簡單的控制器、hystrix 和上述依賴項,并且指標確實出現在 /actuator/prometheus 中,無需其他步驟。我的應用程序比簡單項目有更多的依賴項,所以我認為其他東西可能會覆蓋/禁用指標綁定。我不僅被告知實際問題是什么,而且還在努力嘗試了解如何解決此類問題。是否有任何可以激活的千分尺/Spring 啟動日志(自動配置報告除外)來了解發生了什么?
查看完整描述

1 回答

?
慕沐林林

TA貢獻2016條經驗 獲得超9個贊

在遵循整個自定義 hystrix 指標綁定過程之后,我最終發現一切都被正確綁定,至少在原則上是這樣。


然后,我嘗試在第一次執行 hystrix 命令時觸發斷點,以檢查注冊表和發布者的情況。在方法中放置斷點


HystrixMetricsPublisherThreadPool getPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties)

在HystrixMetricsPublisherFactory課堂上,我發現該HystrixPlugins實例與設置發布者的時刻不同。檢查應用程序的所有代碼后,我發現為了設置自定義事件通知程序,實例正在重置。


@EventListener(ApplicationReadyEvent.class)

    public void doAfterStartup() {

        Hystrix.reset();

        registerCustomHystrixEventNotifier(circuitBreakerHystrixEventNotifier);

        logger.info("hello world, application started up");

    }

然后,我修改了該方法以注冊事件通知程序,而無需重置之前配置的自動配置,并且 hystrix 指標現在顯示在 prometheus 端點中。


查看完整回答
反對 回復 2023-07-19
  • 1 回答
  • 0 關注
  • 210 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號