[英]How to define additional or custom tags for default Spring Boot 2 metrics?
[英]Is there a possibility to add custom spring boot metrics tags at runtime?
我正在使用帶有 micrometer-registry-prometheus 的 Spring 引導,嘗試存儲來自 http 標頭、安全上下文等的自定義標簽。
於是我找到了 MeterFilter iterface,並嘗試用它來存儲我需要的數據。
但是 MeterFilter 方法在請求完成后起作用,所以那時我沒有任何關於請求的信息。
似乎這種情況很常見,有沒有可能實現它?
如果您使用的是 Spring MVC,您可以定義一個實現WebMvcTagsProvider
的 bean,以完全控制添加到請求-響應交換指標的標簽。 或者,您可以定義一個實現WebMvcTagsContributor
的 bean 以添加到默認標簽。 同樣,如果您使用 Spring WebFlux,您可以定義實現WebFluxTagsProvider
和WebFluxTagsContributor
的 bean 來完全控制標簽並分別貢獻額外的標簽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.