-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Properties to set default configuration for auto-timed controller metrics #15988
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
Closed
ttddyy
wants to merge
1
commit into
spring-projects:master
from
ttddyy:configure-default-auto-timed-controller
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,20 @@ | |
|
||
package org.springframework.boot.actuate.autoconfigure.metrics; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; | ||
|
||
/** | ||
* {@link ConfigurationProperties} for configuring Micrometer-based metrics. | ||
* | ||
* @author Jon Schneider | ||
* @author Alexander Abramov | ||
* @author Tadaya Tsuyukubo | ||
* @since 2.0.0 | ||
*/ | ||
@ConfigurationProperties("management.metrics") | ||
|
@@ -93,10 +97,79 @@ public Server getServer() { | |
|
||
public static class Client { | ||
|
||
private final ClientRequest request = new ClientRequest(); | ||
|
||
/** | ||
* 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. | ||
*/ | ||
private int maxUriTags = 100; | ||
|
||
/** | ||
* Name of the metric for sent requests. | ||
* Get name of the metric for received requests. | ||
* @return request metric name | ||
* @deprecated since 2.2.0 in favor of {@link ClientRequest#getMetricName()} | ||
*/ | ||
private String requestsMetricName = "http.client.requests"; | ||
@DeprecatedConfigurationProperty( | ||
replacement = "management.metrics.web.client.request.metric-name") | ||
public String getRequestsMetricName() { | ||
return this.request.getMetricName(); | ||
} | ||
|
||
/** | ||
* Set name of the metric for received requests. | ||
* @param requestsMetricName request metric name | ||
* @deprecated since 2.2.0 in favor of | ||
* {@link ClientRequest#setMetricName(String)} | ||
*/ | ||
public void setRequestsMetricName(String requestsMetricName) { | ||
this.request.setMetricName(requestsMetricName); | ||
} | ||
|
||
public ClientRequest getRequest() { | ||
return this.request; | ||
} | ||
|
||
public int getMaxUriTags() { | ||
return this.maxUriTags; | ||
} | ||
|
||
public void setMaxUriTags(int maxUriTags) { | ||
this.maxUriTags = maxUriTags; | ||
} | ||
|
||
public static class ClientRequest { | ||
|
||
/** | ||
* Name of the metric for sent requests. | ||
*/ | ||
private String metricName = "http.client.requests"; | ||
|
||
/** | ||
* Automatically time requests. | ||
*/ | ||
private final AutoTime autoTime = new AutoTime(); | ||
|
||
public AutoTime getAutoTime() { | ||
return this.autoTime; | ||
} | ||
|
||
public String getMetricName() { | ||
return this.metricName; | ||
} | ||
|
||
public void setMetricName(String metricName) { | ||
this.metricName = metricName; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
public static class Server { | ||
|
||
private final ServerRequest request = new ServerRequest(); | ||
|
||
/** | ||
* Maximum number of unique URI tag values allowed. After the max number of | ||
|
@@ -105,12 +178,29 @@ public static class Client { | |
*/ | ||
private int maxUriTags = 100; | ||
|
||
/** | ||
* Get name of the metric for received requests. | ||
* @return request metric name | ||
* @deprecated since 2.2.0 in favor of {@link ServerRequest#getMetricName()} | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have a @DeprecatedConfigurationProperty with the replacement key |
||
@DeprecatedConfigurationProperty( | ||
replacement = "management.metrics.web.server.request.metric-name") | ||
public String getRequestsMetricName() { | ||
return this.requestsMetricName; | ||
return this.request.getMetricName(); | ||
} | ||
|
||
/** | ||
* Set name of the metric for received requests. | ||
* @param requestsMetricName request metric name | ||
* @deprecated since 2.2.0 in favor of | ||
* {@link ServerRequest#setMetricName(String)} | ||
*/ | ||
public void setRequestsMetricName(String requestsMetricName) { | ||
this.requestsMetricName = requestsMetricName; | ||
this.request.setMetricName(requestsMetricName); | ||
} | ||
|
||
public ServerRequest getRequest() { | ||
return this.request; | ||
} | ||
|
||
public int getMaxUriTags() { | ||
|
@@ -121,52 +211,80 @@ public void setMaxUriTags(int maxUriTags) { | |
this.maxUriTags = maxUriTags; | ||
} | ||
|
||
public static class ServerRequest { | ||
|
||
/** | ||
* Name of the metric for received requests. | ||
*/ | ||
private String metricName = "http.server.requests"; | ||
|
||
/** | ||
* Automatically time requests. | ||
*/ | ||
private final AutoTime autoTime = new AutoTime(); | ||
|
||
public AutoTime getAutoTime() { | ||
return this.autoTime; | ||
} | ||
|
||
public String getMetricName() { | ||
return this.metricName; | ||
} | ||
|
||
public void setMetricName(String metricName) { | ||
this.metricName = metricName; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
public static class Server { | ||
public static class AutoTime { | ||
|
||
/** | ||
* Whether requests handled by Spring MVC, WebFlux or Jersey should be | ||
* automatically timed. If the number of time series emitted grows too large | ||
* on account of request mapping timings, disable this and use 'Timed' on a | ||
* per request mapping basis as needed. | ||
*/ | ||
private boolean autoTimeRequests = true; | ||
private boolean enabled = true; | ||
|
||
/** | ||
* Name of the metric for received requests. | ||
* Default percentiles when @Timed annotation is not presented on the | ||
* corresponding request handler. Any @Timed annotation presented will have | ||
* precedence. | ||
*/ | ||
private String requestsMetricName = "http.server.requests"; | ||
private List<Double> defaultPercentiles = new ArrayList<>(); | ||
|
||
/** | ||
* 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. | ||
* Default histogram when @Timed annotation is not presented on the | ||
* corresponding request handler. Any @Timed annotation presented will have | ||
* precedence. | ||
*/ | ||
private int maxUriTags = 100; | ||
private boolean defaultHistogram; | ||
|
||
public boolean isAutoTimeRequests() { | ||
return this.autoTimeRequests; | ||
public boolean isEnabled() { | ||
return this.enabled; | ||
} | ||
|
||
public void setAutoTimeRequests(boolean autoTimeRequests) { | ||
this.autoTimeRequests = autoTimeRequests; | ||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public String getRequestsMetricName() { | ||
return this.requestsMetricName; | ||
public List<Double> getDefaultPercentiles() { | ||
return this.defaultPercentiles; | ||
} | ||
|
||
public void setRequestsMetricName(String requestsMetricName) { | ||
this.requestsMetricName = requestsMetricName; | ||
public void setDefaultPercentiles(List<Double> defaultPercentiles) { | ||
this.defaultPercentiles = defaultPercentiles; | ||
} | ||
|
||
public int getMaxUriTags() { | ||
return this.maxUriTags; | ||
public boolean isDefaultHistogram() { | ||
return this.defaultHistogram; | ||
} | ||
|
||
public void setMaxUriTags(int maxUriTags) { | ||
this.maxUriTags = maxUriTags; | ||
public void setDefaultHistogram(boolean defaultHistogram) { | ||
this.defaultHistogram = defaultHistogram; | ||
} | ||
|
||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a
@DeprecatedConfigurationProperty
with the replacement key