-
Notifications
You must be signed in to change notification settings - Fork 96
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
ResponseException stores the JSON sent to Druid. #70
Conversation
52883ad
to
7206352
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look too bad, just 1 main concern really.
@@ -37,6 +45,29 @@ public ResponseException(Response.StatusType statusType, DruidAggregationQuery<? | |||
} | |||
|
|||
/** | |||
* Class constructor with throwable, other parameters and a mapper for serializing the druid query. | |||
* @param statusType Status type of the response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space needed
@@ -64,7 +95,29 @@ public ResponseException( | |||
DruidQuery<?> druidQuery, | |||
Throwable cause | |||
) { | |||
super(buildMessage(reason, description, statusCode, druidQuery, cause)); | |||
this(statusCode, reason, description, druidQuery, cause, new ObjectMapper().writer()); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deprecate this constructor, since creating a new "naked" mapper w/o the extensions we have on the primary ones will result in a funky serialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And by that token, probably deprecate other constructors to this thing that don't take in the writer they'll need as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and also not increase the number of deprecation warnings the compiler throws at us if we can 😉
7adaf34
to
cbb204e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than flipping those 2 lines. 👍
druidQueryString = objectWriter.writeValueAsString(druidQuery); | ||
} catch (JsonProcessingException e) { | ||
druidQueryString = druidQuery.toString(); | ||
LOG.warn(String.format("Failed to properly serialize druid query %s", druidQueryString), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flip these. Otherwise, if the toString()
blows up, we never see the next log message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, then the best we can say is "Failed to properly serialize a druid query." without any sort of string representation. Which admittedly isn't going to be that different from what will be displayed now, since we don't override toString
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense. With that in mind, you can actually just in-line druidQuery
in the LOG
call, and let the logging framework call toString
if it decides it needs to actually log it.
1bf0d94
to
95f4dea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good. Just remember to squash before merge once this has it's 2 +1s
👍 |
-- `DruidAggregationQuery` does not have `toString` defined. Furthermore, it would be non-trivial to define a `toString` that serializes the query into the actual query sent to Druid (we would need to inject a `ObjectMapper` from the `ObjectMapperSuite` into the aggregation query). Therefore, the `ResponseException` now takes an `ObjectWriter` that can be used to serialize the druid query that is logged.
95f4dea
to
aac87bc
Compare
--
DruidAggregationQuery
does not havetoString
defined.Furthermore, it would be non-trivial to define a
toString
thatserializes the query into the actual query sent to Druid (we would need
to inject a
ObjectMapper
from theObjectMapperSuite
into theaggregation query). Therefore, the
ResponseException
now takes anObjectWriter
that can be used to serialize the druid query that islogged.