Skip to content
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

Limit metrics collection of incoming requests #14173

Closed
wants to merge 1 commit into from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Aug 22, 2018

see gh-13913.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 22, 2018
@nosan nosan force-pushed the gh-13913 branch 2 times, most recently from 6904c10 to 75733ba Compare August 23, 2018 09:18
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 24, 2018
@snicoll snicoll added this to the 2.0.x milestone Aug 24, 2018
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the PR @nosan!

I've added a few suggestions and am looking forward to your feedback on them. In particular, I'd like this PR to be minimal considering we target a maintenance release.

/**
* {@link MeterFilter} to log only once a warning message and deny {@link Meter.Id}.
*
* @author Dmytro Nosan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a @since. I wonder if that wouldn't be something of interest for the library (ping @jkschneider)

@@ -90,7 +91,7 @@ private MetricsRun() {
* implementation.
* @return the function to apply
*/
public static Function<ApplicationContextRunner, ApplicationContextRunner> simple() {
public static <T extends AbstractApplicationContextRunner> Function<T, T> simple() {
Copy link
Member

@snicoll snicoll Aug 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly related to the scope of this PR. I am happy to revisit the tests here but I'd like to do that in a separate PR.

Could you please revert everything that's related to that?

(also if submit a new PR for this, there is a raw type use of AbstractApplicationContextRunner)


/**
* Tests for {@link WebMvcMetricsAutoConfiguration}.
*
* @author Andy Wilkinson
* @author Dmytro Nosan
*/
public class WebMvcMetricsAutoConfigurationTests {

private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I prefer the former. I'd rather keep the auto-configurations explicit and only add what's strictly necessary for the task at hand (anyway, to be discussed in a separate PR anyway).

@@ -1489,6 +1489,8 @@ content into your application. Rather, pick only the properties that you need.
management.metrics.web.client.requests-metric-name=http.client.requests # Name of the metric for sent requests.
management.metrics.web.server.auto-time-requests=true # Whether requests handled by Spring MVC or WebFlux should be automatically timed.
management.metrics.web.server.requests-metric-name=http.server.requests # Name of the metric for received requests.
management.metrics.web.server.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line to be removed here please.

@@ -1489,6 +1489,8 @@ content into your application. Rather, pick only the properties that you need.
management.metrics.web.client.requests-metric-name=http.client.requests # Name of the metric for sent requests.
management.metrics.web.server.auto-time-requests=true # Whether requests handled by Spring MVC or WebFlux should be automatically timed.
management.metrics.web.server.requests-metric-name=http.server.requests # Name of the metric for received requests.
management.metrics.web.server.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please order the key alphabetically.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Aug 28, 2018
@nosan nosan force-pushed the gh-13913 branch 4 times, most recently from 3abd033 to f55065b Compare August 28, 2018 20:17
@nosan
Copy link
Contributor Author

nosan commented Aug 28, 2018

Thanks, @snicoll
PR has been updated.

@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Aug 29, 2018
@snicoll
Copy link
Member

snicoll commented Aug 29, 2018

@nosan thanks for the feedback but I still see some unrelated changes in WebMvcMetricsAutoConfigurationTests. Can you please remove those? The test you've added there imports WebMvcMetricsAutoConfiguration again.

If you rebase to a single commit, then a diff should show a focused minimal change for this test as well. Thanks a lot for your efforts!

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Aug 29, 2018
@nosan
Copy link
Contributor Author

nosan commented Aug 29, 2018

@snicoll
updated :)

@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Aug 30, 2018
@snicoll snicoll self-assigned this Aug 30, 2018
@snicoll snicoll changed the title Add support MeterFilter#maximumAllowableTags for WebFlux and WebMvc Limit metrics collection of incoming requests Aug 30, 2018
@nosan
Copy link
Contributor Author

nosan commented Aug 30, 2018

@snicoll I see that WebClientMetricsAutoConfiguration doesn't have a MeterFilter for uri tags as well. Should I add it?

@snicoll
Copy link
Member

snicoll commented Aug 30, 2018

@nosan ah ah that's awesome, I just saw that as well 5 min ago. I think so yeah, looks like an oversight. This should be done as a separate issue/PR though. Do you want to give that a try? (I am almost done with this one).

@nosan
Copy link
Contributor Author

nosan commented Aug 30, 2018

@snicoll I'll create a separate PR.

snicoll pushed a commit that referenced this pull request Aug 30, 2018
snicoll added a commit that referenced this pull request Aug 30, 2018
* pr/14173:
  Polish "Limit metrics collection of incoming requests"
  Limit metrics collection of incoming requests
@snicoll
Copy link
Member

snicoll commented Aug 30, 2018

@nosan I am confused, there is a test for this in WebClientMetricsAutoConfigurationTests. It's on master only, that's why I thought it was an oversight when I was in 2.0.x.

@nosan
Copy link
Contributor Author

nosan commented Aug 30, 2018

@snicoll RestTemplateMetricsAutoConfiguration

	@Bean
	@Order(0)
	public MeterFilter metricsHttpClientUriTagFilter(MetricsProperties properties) {
		String metricName = properties.getWeb().getClient().getRequestsMetricName();
		MeterFilter denyFilter = new MaximumUriTagsReachedMeterFilter(metricName);
		return MeterFilter.maximumAllowableTags(metricName, "uri",
				properties.getWeb().getClient().getMaxUriTags(), denyFilter);
	}

@snicoll snicoll modified the milestones: 2.0.x, 2.0.5 Aug 30, 2018
@snicoll snicoll closed this in 0625443 Aug 30, 2018
@snicoll
Copy link
Member

snicoll commented Aug 30, 2018

I don't understand why you refer to it. Metrics support for WebClient was added in #12228.

@nosan
Copy link
Contributor Author

nosan commented Aug 30, 2018

I'm talking about 'uri' tag filter. If you remove RestTemplateMetricsAutoConfiguration from MetricsRun.simple() in WebClientMetricsAutoConfigurationTests then afterMaxUrisReachedFurtherUrisAreDenied test will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants