-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Better harmonized dimensions for query metrics. #3245
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ | |
import io.druid.query.QueryContextKeys; | ||
import io.druid.query.QueryInterruptedException; | ||
import io.druid.query.QuerySegmentWalker; | ||
import io.druid.query.QueryToolChest; | ||
import io.druid.query.QueryToolChestWarehouse; | ||
import io.druid.server.initialization.ServerConfig; | ||
import io.druid.server.log.RequestLogger; | ||
import io.druid.server.security.Access; | ||
|
@@ -83,6 +85,7 @@ public class QueryResource | |
|
||
private static final int RESPONSE_CTX_HEADER_LEN_LIMIT = 7*1024; | ||
|
||
private final QueryToolChestWarehouse warehouse; | ||
private final ServerConfig config; | ||
private final ObjectMapper jsonMapper; | ||
private final ObjectMapper smileMapper; | ||
|
@@ -94,6 +97,7 @@ public class QueryResource | |
|
||
@Inject | ||
public QueryResource( | ||
QueryToolChestWarehouse warehouse, | ||
ServerConfig config, | ||
@Json ObjectMapper jsonMapper, | ||
@Smile ObjectMapper smileMapper, | ||
|
@@ -104,6 +108,7 @@ public QueryResource( | |
AuthConfig authConfig | ||
) | ||
{ | ||
this.warehouse = warehouse; | ||
this.config = config; | ||
this.jsonMapper = jsonMapper; | ||
this.smileMapper = smileMapper; | ||
|
@@ -159,6 +164,7 @@ public Response doPost( | |
{ | ||
final long start = System.currentTimeMillis(); | ||
Query query = null; | ||
QueryToolChest toolChest = null; | ||
String queryId = null; | ||
|
||
final String reqContentType = req.getContentType(); | ||
|
@@ -187,6 +193,7 @@ public Response doPost( | |
) | ||
); | ||
} | ||
toolChest = warehouse.getToolChest(query); | ||
|
||
Thread.currentThread() | ||
.setName(String.format("%s[%s_%s_%s]", currThreadName, query.getType(), query.getDataSource(), queryId)); | ||
|
@@ -236,6 +243,7 @@ public Object accumulate(Object accumulated, Object in) | |
|
||
try { | ||
final Query theQuery = query; | ||
final QueryToolChest theToolChest = toolChest; | ||
Response.ResponseBuilder builder = Response | ||
.ok( | ||
new StreamingOutput() | ||
|
@@ -252,12 +260,12 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE | |
|
||
final long queryTime = System.currentTimeMillis() - start; | ||
emitter.emit( | ||
DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr()) | ||
DruidMetrics.makeQueryTimeMetric(theToolChest, jsonMapper, theQuery, req.getRemoteAddr()) | ||
.setDimension("success", "true") | ||
.build("query/time", queryTime) | ||
); | ||
emitter.emit( | ||
DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr()) | ||
DruidMetrics.makeQueryTimeMetric(theToolChest, jsonMapper, theQuery, req.getRemoteAddr()) | ||
.build("query/bytes", os.getCount()) | ||
); | ||
|
||
|
@@ -309,7 +317,7 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE | |
log.info("%s [%s]", e.getMessage(), queryId); | ||
final long queryTime = System.currentTimeMillis() - start; | ||
emitter.emit( | ||
DruidMetrics.makeQueryTimeMetric(jsonMapper, query, req.getRemoteAddr()) | ||
DruidMetrics.makeQueryTimeMetric(toolChest, jsonMapper, query, req.getRemoteAddr()) | ||
.setDimension("success", "false") | ||
.build("query/time", queryTime) | ||
); | ||
|
@@ -356,7 +364,7 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE | |
try { | ||
final long queryTime = System.currentTimeMillis() - start; | ||
emitter.emit( | ||
DruidMetrics.makeQueryTimeMetric(jsonMapper, query, req.getRemoteAddr()) | ||
DruidMetrics.makeQueryTimeMetric(toolChest, jsonMapper, query, req.getRemoteAddr()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. toolchest can possibly be null here, do we need to handle that case ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.setDimension("success", "false") | ||
.build("query/time", queryTime) | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm reading this correct, the only reason you need to have a 2nd variable name here is because the two code paths of A) query successfully deserializing and B) query throws exception while deserializing... are all muddled together in the exception handling.
Would it be worth it in this PR to try and clean that up a bit?
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.
This is here because the query and toolChest are passed to anonymous classes at some point, and so the references need to be final. But the original references aren't final due to how the exception handling is done.
I didn't really want to mess with any of that in this PR.
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.
Sure, I figured it would probably be outside the scope of this PR, but should be refactored before too many work-arounds are added.