Skip to content
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

Rename http.*.duration to http.*.request.duration #9089

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ public static OperationMetrics get() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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 =
Expand All @@ -33,17 +33,20 @@ 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));
}
return durationBuilder.build();
}

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() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ private HttpServerMetrics(Meter meter) {
.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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void collectsMetrics() {
.satisfiesExactlyInAnyOrder(
metric ->
assertThat(metric)
.hasName("http.client.duration")
.hasName("http.client.request.duration")
.hasUnit("s")
.hasHistogramSatisfying(
histogram ->
Expand Down Expand Up @@ -114,7 +114,7 @@ void collectsMetrics() {
.satisfiesExactlyInAnyOrder(
metric ->
assertThat(metric)
.hasName("http.client.duration")
.hasName("http.client.request.duration")
.hasHistogramSatisfying(
histogram ->
histogram.hasPointsSatisfying(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void collectsMetrics() {
.hasSpanId(spanContext1.getSpanId())))),
metric ->
assertThat(metric)
.hasName("http.server.duration")
.hasName("http.server.request.duration")
.hasUnit("s")
.hasHistogramSatisfying(
histogram ->
Expand Down Expand Up @@ -235,7 +235,7 @@ void collectsMetrics() {
.hasSpanId(spanContext2.getSpanId())))),
metric ->
assertThat(metric)
.hasName("http.server.duration")
.hasName("http.server.request.duration")
.hasHistogramSatisfying(
histogram ->
histogram.hasPointsSatisfying(
Expand Down Expand Up @@ -306,7 +306,7 @@ void collectsHttpRouteFromEndAttributes() {
.anySatisfy(
metric ->
assertThat(metric)
.hasName("http.server.duration")
.hasName("http.server.request.duration")
.hasUnit("s")
.hasHistogramSatisfying(
histogram ->
Expand Down