Align server contextual names with OTel conventions
This commit ensures that the matching path pattern for the request being
observed is used in the conytextual name, as advised in the OTel HTTP
server semantic conventions.
If the path pattern is not available, no additional value is provided
and the "http {method}" baseline is being used.
Fixes gh-29424
This commit is contained in:
@@ -76,6 +76,10 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
|
||||
|
||||
@Override
|
||||
public String getContextualName(ServerRequestObservationContext context) {
|
||||
if (context.getPathPattern() != null) {
|
||||
return String.format("http %s %s", context.getCarrier().getMethod().toLowerCase(),
|
||||
context.getPathPattern());
|
||||
}
|
||||
return "http " + context.getCarrier().getMethod().toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,10 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
|
||||
|
||||
@Override
|
||||
public String getContextualName(ServerRequestObservationContext context) {
|
||||
if (context.getPathPattern() != null) {
|
||||
return String.format("http %s %s", context.getCarrier().getMethod().name().toLowerCase(),
|
||||
context.getPathPattern().toString());
|
||||
}
|
||||
return "http " + context.getCarrier().getMethod().name().toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user