Hello community 👋,
We have a test that validates the http.server.requests metric with tags collected in Micrometer in spring-graphql application as follows:
assertThat(meterRegistry
.timer(
"http.server.requests",
Tags.of(
"error", "none",
"exception", "none",
"method", "POST",
"outcome", "SUCCESS",
"status", "200",
"uri", "/graphql",
"user", warmupUserName))
.count())
.isEqualTo(400);
Issue
After upgrading to Spring Boot version 3.3.0, this test is failing. Upon debugging, I discovered that the low-cardinality key uri is now being reported as UNKNOWN in DefaultServerRequestObservationConvention.
Since spring boot 3.3.0 includes dependency update for graphql-java v22.0 can you help me to find the root cause of the uri being collected as UNKNOWN
Comment From: bclozel
Can you share a minimal sample we can have a look at?
Comment From: nodshams
Hey @bclozel,
test is quite simple. We have DataDog dashboards that expect certain tags in the http.server.requests metric reported by our application. To ensure these metrics are reported correctly with all necessary tags, we have a simple test.
it's not visible here but before the test starts, we run a warmup client that sends 400 requests to the /graphql endpoint (localhost:8080/graphql) on onApplicationEvent to warm up the application.
@Test
public void it_pongs() {
RestTemplate restTemplate = builder.build();
assertThat(restTemplate
.getForEntity("http://localhost:53609/ping", Void.class)
.getStatusCode())
.isEqualTo(HttpStatus.OK);
assertThat(meterRegistry
.timer(
"http.server.requests",
Tags.of(
"error", "none",
"exception", "none",
"method", "POST",
"outcome", "SUCCESS",
"status", "200",
"uri", "/graphql",
"user", warmupUserName))
.count())
.isEqualTo(400);
}
Issue
After upgrading to Spring Boot version 3.3.0, this test is now failing. The uri tag is being reported as UNKNOWN instead of /graphql.
Comment From: nodshams
forgot to mention, we haveExtendedServerRequestObservationConvention to collect customs tags for http.server.requests
public class ExtendedServerRequestObservationConvention extends DefaultServerRequestObservationConvention {
@NotNull @Override
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
return super.getLowCardinalityKeyValues(context).and(custom(context));
}
@NotNull @Override
public KeyValues getHighCardinalityKeyValues(ServerRequestObservationContext context) {
return super.getHighCardinalityKeyValues(context).and(custom(context));
}
protected KeyValue custom(ServerRequestObservationContext context) {
return KeyValue.of(
"user",
SecurityHelper.extractUserNameFromAuthHeaderOrDefault(
context.getCarrier().getHeader(HttpHeaders.AUTHORIZATION)));
}
}
Comment From: bclozel
I don't think anything there is relevant to the issue, this information is missing out of the box at runtime, even without custom conventions. I've created https://github.com/spring-projects/spring-graphql/issues/987 to track this.