Skip to content

Commit 8b96d89

Browse files
committed
Add try-catch protection to HttpEndpointPostProcessor
1 parent b6bb012 commit 8b96d89

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

dd-trace-core/src/main/java/datadog/trace/core/tagprocessor/HttpEndpointPostProcessor.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,31 @@ public void processTags(
8484
return;
8585
}
8686

87-
String httpMethod = httpMethodObj.toString();
88-
String httpRoute = httpRouteObj != null ? httpRouteObj.toString() : null;
89-
String httpUrl = httpUrlObj != null ? httpUrlObj.toString() : null;
87+
try {
88+
String httpMethod = httpMethodObj.toString();
89+
String httpRoute = httpRouteObj != null ? httpRouteObj.toString() : null;
90+
String httpUrl = httpUrlObj != null ? httpUrlObj.toString() : null;
9091

91-
// Resolve endpoint using EndpointResolver
92-
// Pass unsafeTags directly - it's safe to use at this point since span is finished
93-
String endpoint = endpointResolver.resolveEndpoint(unsafeTags, httpRoute, httpUrl);
92+
// Resolve endpoint using EndpointResolver
93+
// Pass unsafeTags directly - it's safe to use at this point since span is finished
94+
String endpoint = endpointResolver.resolveEndpoint(unsafeTags, httpRoute, httpUrl);
9495

95-
if (endpoint != null && !endpoint.isEmpty()) {
96-
// Combine method and endpoint into resource name using cached join
97-
CharSequence resourceName = HttpResourceNames.join(httpMethod, endpoint);
98-
spanContext.setResourceName(
99-
resourceName, ResourceNamePriorities.HTTP_SERVER_RESOURCE_RENAMING);
96+
if (endpoint != null && !endpoint.isEmpty()) {
97+
// Combine method and endpoint into resource name using cached join
98+
CharSequence resourceName = HttpResourceNames.join(httpMethod, endpoint);
99+
spanContext.setResourceName(
100+
resourceName, ResourceNamePriorities.HTTP_SERVER_RESOURCE_RENAMING);
100101

101-
log.debug(
102-
"Updated resource name to '{}' for span {} (method={}, route={}, url={})",
103-
resourceName,
104-
spanContext.getSpanId(),
105-
httpMethod,
106-
httpRoute,
107-
httpUrl);
102+
log.debug(
103+
"Updated resource name to '{}' for span {} (method={}, route={}, url={})",
104+
resourceName,
105+
spanContext.getSpanId(),
106+
httpMethod,
107+
httpRoute,
108+
httpUrl);
109+
}
110+
} catch (Throwable t) {
111+
log.debug("Error processing HTTP endpoint for span {}", spanContext.getSpanId(), t);
108112
}
109113
}
110114
}

0 commit comments

Comments
 (0)