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 HttpClientMetrics(Meter meter) {
|
||||
String durationInstrumentName =
|
||||
HttpMetricsUtil.emitNewSemconvMetrics
|
||||
? "http.client.request.duration"
|
||||
: "http.client.duration";
|
||||
duration =
|
||||
createDurationHistogram(
|
||||
meter, "http.client.duration", "The duration of the outbound HTTP request");
|
||||
meter, durationInstrumentName, "The duration of the outbound HTTP request");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
|||
final class HttpMetricsUtil {
|
||||
|
||||
// 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();
|
||||
|
||||
static final List<Double> DURATION_SECONDS_BUCKETS =
|
||||
|
@ -33,9 +33,12 @@ final class HttpMetricsUtil {
|
|||
|
||||
static DoubleHistogram createDurationHistogram(Meter meter, String name, String description) {
|
||||
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
|
||||
if (useSeconds && durationBuilder instanceof ExtendedDoubleHistogramBuilder) {
|
||||
if (emitNewSemconvMetrics && durationBuilder instanceof ExtendedDoubleHistogramBuilder) {
|
||||
((ExtendedDoubleHistogramBuilder) durationBuilder)
|
||||
.setAdvice(advice -> advice.setExplicitBucketBoundaries(DURATION_SECONDS_BUCKETS));
|
||||
}
|
||||
|
@ -43,7 +46,7 @@ final class HttpMetricsUtil {
|
|||
}
|
||||
|
||||
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() {}
|
||||
|
|
|
@ -58,9 +58,13 @@ public final class HttpServerMetrics implements OperationListener {
|
|||
.setUnit("{requests}")
|
||||
.setDescription("The number of concurrent HTTP requests that are currently in-flight")
|
||||
.build();
|
||||
String durationInstrumentName =
|
||||
HttpMetricsUtil.emitNewSemconvMetrics
|
||||
? "http.server.request.duration"
|
||||
: "http.server.duration";
|
||||
duration =
|
||||
createDurationHistogram(
|
||||
meter, "http.server.duration", "The duration of the inbound HTTP request");
|
||||
meter, durationInstrumentName, "The duration of the inbound HTTP request");
|
||||
requestSize =
|
||||
meter
|
||||
.histogramBuilder("http.server.request.size")
|
||||
|
|
|
@ -82,7 +82,7 @@ class HttpClientMetricsStableSemconvTest {
|
|||
.satisfiesExactlyInAnyOrder(
|
||||
metric ->
|
||||
assertThat(metric)
|
||||
.hasName("http.client.duration")
|
||||
.hasName("http.client.request.duration")
|
||||
.hasUnit("s")
|
||||
.hasHistogramSatisfying(
|
||||
histogram ->
|
||||
|
@ -114,7 +114,7 @@ class HttpClientMetricsStableSemconvTest {
|
|||
.satisfiesExactlyInAnyOrder(
|
||||
metric ->
|
||||
assertThat(metric)
|
||||
.hasName("http.client.duration")
|
||||
.hasName("http.client.request.duration")
|
||||
.hasHistogramSatisfying(
|
||||
histogram ->
|
||||
histogram.hasPointsSatisfying(
|
||||
|
|
|
@ -146,7 +146,7 @@ class HttpServerMetricsStableSemconvTest {
|
|||
.hasSpanId(spanContext1.getSpanId())))),
|
||||
metric ->
|
||||
assertThat(metric)
|
||||
.hasName("http.server.duration")
|
||||
.hasName("http.server.request.duration")
|
||||
.hasUnit("s")
|
||||
.hasHistogramSatisfying(
|
||||
histogram ->
|
||||
|
@ -235,7 +235,7 @@ class HttpServerMetricsStableSemconvTest {
|
|||
.hasSpanId(spanContext2.getSpanId())))),
|
||||
metric ->
|
||||
assertThat(metric)
|
||||
.hasName("http.server.duration")
|
||||
.hasName("http.server.request.duration")
|
||||
.hasHistogramSatisfying(
|
||||
histogram ->
|
||||
histogram.hasPointsSatisfying(
|
||||
|
@ -306,7 +306,7 @@ class HttpServerMetricsStableSemconvTest {
|
|||
.anySatisfy(
|
||||
metric ->
|
||||
assertThat(metric)
|
||||
.hasName("http.server.duration")
|
||||
.hasName("http.server.request.duration")
|
||||
.hasUnit("s")
|
||||
.hasHistogramSatisfying(
|
||||
histogram ->
|
||||
|
|
Loading…
Reference in New Issue