Rename `http.*.duration` to `http.*.request.duration` (#9089)
This commit is contained in:
parent
01883e3b2e
commit
ff55471b08
|
@ -44,9 +44,13 @@ public final class HttpClientMetrics implements OperationListener {
|
||||||
private final DoubleHistogram duration;
|
private final DoubleHistogram duration;
|
||||||
|
|
||||||
private HttpClientMetrics(Meter meter) {
|
private HttpClientMetrics(Meter meter) {
|
||||||
|
String durationInstrumentName =
|
||||||
|
HttpMetricsUtil.emitNewSemconvMetrics
|
||||||
|
? "http.client.request.duration"
|
||||||
|
: "http.client.duration";
|
||||||
duration =
|
duration =
|
||||||
createDurationHistogram(
|
createDurationHistogram(
|
||||||
meter, "http.client.duration", "The duration of the outbound HTTP request");
|
meter, durationInstrumentName, "The duration of the outbound HTTP request");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
final class HttpMetricsUtil {
|
final class HttpMetricsUtil {
|
||||||
|
|
||||||
// we'll use the old unit if the old semconv is in use
|
// we'll use the old unit if the old semconv is in use
|
||||||
private static final boolean useSeconds =
|
static final boolean emitNewSemconvMetrics =
|
||||||
SemconvStability.emitStableHttpSemconv() && !SemconvStability.emitOldHttpSemconv();
|
SemconvStability.emitStableHttpSemconv() && !SemconvStability.emitOldHttpSemconv();
|
||||||
|
|
||||||
static final List<Double> DURATION_SECONDS_BUCKETS =
|
static final List<Double> DURATION_SECONDS_BUCKETS =
|
||||||
|
@ -33,9 +33,12 @@ final class HttpMetricsUtil {
|
||||||
|
|
||||||
static DoubleHistogram createDurationHistogram(Meter meter, String name, String description) {
|
static DoubleHistogram createDurationHistogram(Meter meter, String name, String description) {
|
||||||
DoubleHistogramBuilder durationBuilder =
|
DoubleHistogramBuilder durationBuilder =
|
||||||
meter.histogramBuilder(name).setUnit(useSeconds ? "s" : "ms").setDescription(description);
|
meter
|
||||||
|
.histogramBuilder(name)
|
||||||
|
.setUnit(emitNewSemconvMetrics ? "s" : "ms")
|
||||||
|
.setDescription(description);
|
||||||
// don't set custom buckets if milliseconds are still used
|
// don't set custom buckets if milliseconds are still used
|
||||||
if (useSeconds && durationBuilder instanceof ExtendedDoubleHistogramBuilder) {
|
if (emitNewSemconvMetrics && durationBuilder instanceof ExtendedDoubleHistogramBuilder) {
|
||||||
((ExtendedDoubleHistogramBuilder) durationBuilder)
|
((ExtendedDoubleHistogramBuilder) durationBuilder)
|
||||||
.setAdvice(advice -> advice.setExplicitBucketBoundaries(DURATION_SECONDS_BUCKETS));
|
.setAdvice(advice -> advice.setExplicitBucketBoundaries(DURATION_SECONDS_BUCKETS));
|
||||||
}
|
}
|
||||||
|
@ -43,7 +46,7 @@ final class HttpMetricsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
static double nanosToUnit(long durationNanos) {
|
static double nanosToUnit(long durationNanos) {
|
||||||
return durationNanos / (useSeconds ? NANOS_PER_S : NANOS_PER_MS);
|
return durationNanos / (emitNewSemconvMetrics ? NANOS_PER_S : NANOS_PER_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpMetricsUtil() {}
|
private HttpMetricsUtil() {}
|
||||||
|
|
|
@ -58,9 +58,13 @@ public final class HttpServerMetrics implements OperationListener {
|
||||||
.setUnit("{requests}")
|
.setUnit("{requests}")
|
||||||
.setDescription("The number of concurrent HTTP requests that are currently in-flight")
|
.setDescription("The number of concurrent HTTP requests that are currently in-flight")
|
||||||
.build();
|
.build();
|
||||||
|
String durationInstrumentName =
|
||||||
|
HttpMetricsUtil.emitNewSemconvMetrics
|
||||||
|
? "http.server.request.duration"
|
||||||
|
: "http.server.duration";
|
||||||
duration =
|
duration =
|
||||||
createDurationHistogram(
|
createDurationHistogram(
|
||||||
meter, "http.server.duration", "The duration of the inbound HTTP request");
|
meter, durationInstrumentName, "The duration of the inbound HTTP request");
|
||||||
requestSize =
|
requestSize =
|
||||||
meter
|
meter
|
||||||
.histogramBuilder("http.server.request.size")
|
.histogramBuilder("http.server.request.size")
|
||||||
|
|
|
@ -82,7 +82,7 @@ class HttpClientMetricsStableSemconvTest {
|
||||||
.satisfiesExactlyInAnyOrder(
|
.satisfiesExactlyInAnyOrder(
|
||||||
metric ->
|
metric ->
|
||||||
assertThat(metric)
|
assertThat(metric)
|
||||||
.hasName("http.client.duration")
|
.hasName("http.client.request.duration")
|
||||||
.hasUnit("s")
|
.hasUnit("s")
|
||||||
.hasHistogramSatisfying(
|
.hasHistogramSatisfying(
|
||||||
histogram ->
|
histogram ->
|
||||||
|
@ -114,7 +114,7 @@ class HttpClientMetricsStableSemconvTest {
|
||||||
.satisfiesExactlyInAnyOrder(
|
.satisfiesExactlyInAnyOrder(
|
||||||
metric ->
|
metric ->
|
||||||
assertThat(metric)
|
assertThat(metric)
|
||||||
.hasName("http.client.duration")
|
.hasName("http.client.request.duration")
|
||||||
.hasHistogramSatisfying(
|
.hasHistogramSatisfying(
|
||||||
histogram ->
|
histogram ->
|
||||||
histogram.hasPointsSatisfying(
|
histogram.hasPointsSatisfying(
|
||||||
|
|
|
@ -146,7 +146,7 @@ class HttpServerMetricsStableSemconvTest {
|
||||||
.hasSpanId(spanContext1.getSpanId())))),
|
.hasSpanId(spanContext1.getSpanId())))),
|
||||||
metric ->
|
metric ->
|
||||||
assertThat(metric)
|
assertThat(metric)
|
||||||
.hasName("http.server.duration")
|
.hasName("http.server.request.duration")
|
||||||
.hasUnit("s")
|
.hasUnit("s")
|
||||||
.hasHistogramSatisfying(
|
.hasHistogramSatisfying(
|
||||||
histogram ->
|
histogram ->
|
||||||
|
@ -235,7 +235,7 @@ class HttpServerMetricsStableSemconvTest {
|
||||||
.hasSpanId(spanContext2.getSpanId())))),
|
.hasSpanId(spanContext2.getSpanId())))),
|
||||||
metric ->
|
metric ->
|
||||||
assertThat(metric)
|
assertThat(metric)
|
||||||
.hasName("http.server.duration")
|
.hasName("http.server.request.duration")
|
||||||
.hasHistogramSatisfying(
|
.hasHistogramSatisfying(
|
||||||
histogram ->
|
histogram ->
|
||||||
histogram.hasPointsSatisfying(
|
histogram.hasPointsSatisfying(
|
||||||
|
@ -306,7 +306,7 @@ class HttpServerMetricsStableSemconvTest {
|
||||||
.anySatisfy(
|
.anySatisfy(
|
||||||
metric ->
|
metric ->
|
||||||
assertThat(metric)
|
assertThat(metric)
|
||||||
.hasName("http.server.duration")
|
.hasName("http.server.request.duration")
|
||||||
.hasUnit("s")
|
.hasUnit("s")
|
||||||
.hasHistogramSatisfying(
|
.hasHistogramSatisfying(
|
||||||
histogram ->
|
histogram ->
|
||||||
|
|
Loading…
Reference in New Issue