Open froque opened 5 months ago
Hello, thank you for the report. This is marked as an error because it generates an Exception that is not handled within the scope of the span. You can see that the root span for that request (which is also the one bearing the http response code) is not marked as error. What exactly is the behavior you would like to see ?
I see from the screenshot that you are using error tracking, you can mark the issue as "Ignored" if you don't want to see it in the issues list.
What exactly is the behavior you would like to see ?
Since from the HTTP client perspective the response is a HTTP 400 and not HTTP 5xx, I was expecting Datadog to not mark this as an error.
I see from the screenshot that you are using error tracking, you can mark the issue as "Ignored" if you don't want to see it in the issues list.
I missed that. I am going to try it now.
The thing is that where the error is captured, we just see it as an exception being thrown by a Java service, which we record as an error. We don't have information on the HTTP response code at this point in time. When we handle the actual response code, we see it's a 400 and we do not mark that span as error.
I know it's not your code but an open source project, but maybe the issue is that keycloak is using an Exception to handle code flow in a not-so-exceptional situation, which is something regarded as bad practice when writing Java code. One fix would be to rework that code to use a meaningful return status rather than an exception.
Ok. In that case, perhaps a new config similar to DD_TRACE_CLASSES_EXCLUDE and DD_HTTP_SERVER_ERROR_STATUSES to ignore specific exceptions (DD_TRACE_EXCEPTIONS_EXCLUDE)?
Or even better let us define some Java class that can decide if a specific exception should be regarded as an error or not i.e. by looking into the type, attributes or annotations.
This would also allow for a fix for #7141.
using an Exception to handle code flow in a not-so-exceptional situation, which is something regarded as bad practice when writing Java code
Java web frameworks encourage throwing Exceptions from an endpoint method whenever it cannot return a thing of the type it usually returns. The pattern is:
200
response.@Path("animals")
public class AnimalResource {
@GET
@Path("{animal-id}")
public Animal getAnimal(@PathParam("animal-id") String animalId) {
Animal result = Database.findAnimal(animalId);
if (result == null) {
throw new WebApplicationException("Animal not found", 404);
}
return result;
}
}
When Datadog traces this method, it has to make some kind of decision about whether the Exception is "4xx-like" or "5xx-like". Perhaps it needs to know the framework and its exception handling conventions to decide that. Or perhaps it can defer the decision until the enclosing http span knows the http status code. Anyway, this pattern is not only valid but normal.
Datadog cannot know about arbitrary methods of course. But if Datadog auto-detects e.g. JAX-RS methods like this and says it can trace them, it seems to imply that Datadog wants to find a way to interpret exceptions thrown from it, just like it interprets what the web server is doing when it is setting a status code.
(Currently this isn't working, and I think it used to work somehow, but I can't be sure of course.)
Maybe fits better in #7141 but I think it may be the same issue.
Running keycloak:
make a HTTP request to token endpoint with an expired or invalid refresh token
We initially though this was a problem in Keycloak https://github.com/keycloak/keycloak/issues/29451 fixed by https://github.com/keycloak/keycloak/pull/29649 but now it seems to be a problem in dd-java-agent.