Skip to content

Commit

Permalink
Rename property.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek committed Nov 18, 2024
1 parent 3a259ec commit d5d2b78
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ Additional information regarding the service instances, request data, and respon

NOTE: For `WebClient` and `RestClient`-backed load-balancing, we use `uriTemplate` for the `uri` tag whenever available.

TIP: It is possible to disable adding `uri` tag by setting `spring.cloud.loadbalancer.metrics.include-uri-tag` to `false`.
TIP: It is possible to disable adding `path` to `uri` tag by setting `spring.cloud.loadbalancer.stats.include-path` to `false`.

WARNING: As with `RestTemplate`-backed load-balancing, we don't have access to `uriTemplate`, full path is always used in the `uri` tag. In order to avoid high cardinality issues, if path is a high cardinality value (for example, `/orders/\{id\}`, where `id` takes a big number of values), it is strongly recommended to disable adding `uri` tag by setting `spring.cloud.loadbalancer.metrics.include-uri-tag` to `false`.
WARNING: As with `RestTemplate`-backed load-balancing, we don't have access to `uriTemplate`, full path is always used in the `uri` tag. In order to avoid high cardinality issues, if path is a high cardinality value (for example, `/orders/\{id\}`, where `id` takes a big number of values), it is strongly recommended to disable adding path to `uri` tag by setting `spring.cloud.loadbalancer.stats.include-path` to `false`.

NOTE: For some implementations, such as `BlockingLoadBalancerClient`, request and response data might not be available, as we establish generic types from arguments and might not be able to determine the types and read the data.

Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/partials/_configprops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
|spring.cloud.loadbalancer.retry.retryable-exceptions | `+++{}+++` | A `Set` of `Throwable` classes that should trigger a retry.
|spring.cloud.loadbalancer.retry.retryable-status-codes | `+++{}+++` | A `Set` of status codes that should trigger a retry.
|spring.cloud.loadbalancer.service-discovery.timeout | | String representation of Duration of the timeout for calls to service discovery.
|spring.cloud.loadbalancer.stats.include-path | `+++true+++` | Indicates whether the {@code path} should be added to {@code uri} tag in metrics. When {@link RestTemplate} is used to execute load-balanced requests with high cardinality paths, setting it to {@code false} is recommended.
|spring.cloud.loadbalancer.stats.micrometer.enabled | `+++false+++` | Enables Spring Cloud LoadBalancer Micrometer stats.
|spring.cloud.loadbalancer.sticky-session.add-service-instance-cookie | `+++false+++` | Indicates whether a cookie with the newly selected instance should be added by LoadBalancer.
|spring.cloud.loadbalancer.sticky-session.instance-id-cookie-name | `+++sc-lb-instance-id+++` | The name of the cookie holding the preferred instance id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class LoadBalancerProperties {
/**
* Properties for LoadBalancer metrics.
*/
private Metrics metrics = new Metrics();
private Stats stats = new Stats();

public HealthCheck getHealthCheck() {
return healthCheck;
Expand Down Expand Up @@ -170,12 +170,12 @@ public void setCallGetWithRequestOnDelegates(boolean callGetWithRequestOnDelegat
this.callGetWithRequestOnDelegates = callGetWithRequestOnDelegates;
}

public Metrics getMetrics() {
return metrics;
public Stats getStats() {
return stats;
}

public void setMetrics(Metrics metrics) {
this.metrics = metrics;
public void setStats(Stats stats) {
this.stats = stats;
}

public static class StickySession {
Expand Down Expand Up @@ -553,21 +553,21 @@ public void setSize(int size) {

}

public static class Metrics {
public static class Stats {

/**
* Indicates whether the `uri` tag should be added to metrics. When
* {@link RestTemplate} is used to execute load-balanced requests with high
* cardinality paths, setting it to {@code false} is recommended.
* Indicates whether the {@code path} should be added to {@code uri} tag in
* metrics. When {@link RestTemplate} is used to execute load-balanced requests
* with high cardinality paths, setting it to {@code false} is recommended.
*/
private boolean includeUriTag = true;
private boolean includePath = true;

public boolean isIncludeUriTag() {
return includeUriTag;
public boolean isIncludePath() {
return includePath;
}

public void setIncludeUriTag(boolean includeUriTag) {
this.includeUriTag = includeUriTag;
public void setIncludePath(boolean includePath) {
this.includePath = includePath;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static int statusValue(ResponseData responseData) {
}

private String getPath(RequestData requestData) {
if (!properties.getMetrics().isIncludeUriTag()) {
if (!properties.getStats().isIncludePath()) {
return UNKNOWN;
}
Optional<Object> uriTemplateValue = Optional.ofNullable(requestData.getAttributes())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void shouldRecordSuccessfulTimedRequest() {
void shouldNotAddPathValueWhenDisabled() {
ReactiveLoadBalancer.Factory<ServiceInstance> factory = mock(ReactiveLoadBalancer.Factory.class);
LoadBalancerProperties properties = new LoadBalancerProperties();
properties.getMetrics().setIncludeUriTag(false);
properties.getStats().setIncludePath(false);
when(factory.getProperties("test")).thenReturn(properties);
MicrometerStatsLoadBalancerLifecycle statsLifecycle = new MicrometerStatsLoadBalancerLifecycle(meterRegistry,
factory);
Expand Down

0 comments on commit d5d2b78

Please sign in to comment.