New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How disable RestTemplate monitoring #304
Comments
Why don't you use the rest template it URI templates? |
@spencergibb |
@spencergibb Code I am working on cannot be easily refactored. Is there a way to turn off metric gathering for a particular I am using the code below to customize the new MetricsRestTemplateCustomizer( meterRegistry, ( urlTemplate, request, response ) ->
Arrays.asList(
RestTemplateExchangeTags.method(request),
RestTemplateExchangeTags.status(response),
RestTemplateExchangeTags.clientName(request)
),
"myTestMetric"
)
.customize( restTemplate ); This creates a metric called Each request would generate a new metric as the url is very complex. |
I fixed my problem creating the following @Bean
RestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider() {
new RestTemplateExchangeTagsProvider() {
@Override
Iterable<Tag> getTags( String urlTemplate, HttpRequest request, ClientHttpResponse response ) {
Tag uriTag
if ( StringUtils.hasText( urlTemplate ) ) {
uriTag = RestTemplateExchangeTags.uri( urlTemplate )
} else if ( request.URI.path.startsWith( '/faulty-endpoint' ) ) {
uriTag = RestTemplateExchangeTags.uri( request.URI.path )
} else {
uriTag = RestTemplateExchangeTags.uri( request )
}
[ RestTemplateExchangeTags.method( request ),
uriTag,
RestTemplateExchangeTags.status( response ),
RestTemplateExchangeTags.clientName( request ) ]
}
}
} If the The above is simply a slightly modified version of the |
I am calling a third party API for logging the metrics |
@chandreshlko I'm not understanding exactly what you're trying to accomplish. It will probably be easier to figure this out through chat. Feel free to join us on Slack at https://slack.micrometer.io. |
@chandreshlko and @shakuzen I have the same problem, I am invoking rest API that has a path variable like this -> /api/{id} |
@faramarzaf can you ask this question on StackOverflow? Please add to your question the relevant information like: which spring boot version you are using, how are you creating and using the rest template instance, show which metrics are collected. |
There are many such codes in my system:
Each different id will bring a different URI, as well as a new tag. It will take up a lot of memory, so how disable it?
The text was updated successfully, but these errors were encountered: