Skip to content

Commit

Permalink
Update HttpClient#metrics(boolean, Function) and HttpServer#metrics(b…
Browse files Browse the repository at this point in the history
…oolean, Function) javadoc (#2593)
  • Loading branch information
violetagg committed Nov 29, 2022
1 parent 4f79019 commit 9a109b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -62,6 +62,8 @@
import reactor.netty.tcp.SslProvider;
import reactor.netty.tcp.TcpClient;
import reactor.netty.transport.ClientTransport;
import reactor.util.Logger;
import reactor.util.Loggers;
import reactor.util.Metrics;
import reactor.util.annotation.Nullable;

Expand Down Expand Up @@ -1158,6 +1160,9 @@ public final HttpClient mapConnect(
* For example instead of using the actual uri {@code "/users/1"} as uri tag value, templated uri
* {@code "/users/{id}"} can be used.
* <p><strong>Note:</strong>
* It is strongly recommended to provide template-like form for the URIs. Without a conversion to a template-like form,
* each distinct URI leads to the creation of a distinct tag, which takes a lot of memory for the metrics.
* <p><strong>Note:</strong>
* It is strongly recommended applications to configure an upper limit for the number of the URI tags.
* For example:
* <pre class="code">
Expand All @@ -1180,6 +1185,12 @@ public final HttpClient metrics(boolean enable, Function<String, String> uriTagV
"To enable metrics, you must add the dependency `io.micrometer:micrometer-core`" +
" to the class path first");
}
if (uriTagValue == Function.<String>identity()) {
log.debug("Metrics are enabled with [uriTagValue=Function#identity]. " +
"It is strongly recommended to provide template-like form for the URIs. " +
"Without a conversion to a template-like form, each distinct URI leads " +
"to the creation of a distinct tag, which takes a lot of memory for the metrics.");
}
HttpClient dup = duplicate();
dup.configuration().metricsRecorder(() -> configuration().defaultMetricsRecorder());
dup.configuration().uriTagValue = uriTagValue;
Expand Down Expand Up @@ -1582,6 +1593,8 @@ static String reactorNettyVersion() {
.orElse("dev");
}

static final Logger log = Loggers.getLogger(HttpClient.class);

static final String HTTP_SCHEME = "http";

static final String HTTPS_SCHEME = "https";
Expand Down
Expand Up @@ -577,6 +577,9 @@ public final HttpServer maxKeepAliveRequests(int maxKeepAliveRequests) {
* For example instead of using the actual uri {@code "/users/1"} as uri tag value, templated uri
* {@code "/users/{id}"} can be used.
* <p><strong>Note:</strong>
* It is strongly recommended to provide template-like form for the URIs. Without a conversion to a template-like form,
* each distinct URI leads to the creation of a distinct tag, which takes a lot of memory for the metrics.
* <p><strong>Note:</strong>
* It is strongly recommended applications to configure an upper limit for the number of the URI tags.
* For example:
* <pre class="code">
Expand All @@ -599,6 +602,12 @@ public final HttpServer metrics(boolean enable, Function<String, String> uriTagV
"To enable metrics, you must add the dependency `io.micrometer:micrometer-core`" +
" to the class path first");
}
if (uriTagValue == Function.<String>identity()) {
log.debug("Metrics are enabled with [uriTagValue=Function#identity]. " +
"It is strongly recommended to provide template-like form for the URIs. " +
"Without a conversion to a template-like form, each distinct URI leads " +
"to the creation of a distinct tag, which takes a lot of memory for the metrics.");
}
HttpServer dup = duplicate();
dup.configuration().metricsRecorder(() -> configuration().defaultMetricsRecorder());
dup.configuration().uriTagValue = uriTagValue;
Expand Down

0 comments on commit 9a109b1

Please sign in to comment.