-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add logging at main API endpoints (bulk ingest, msearch) when 500 is returned #924
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -92,24 +92,30 @@ public HttpResponse clusterMetadata() { | |||||||||||||||||||||||||||
@Post | ||||||||||||||||||||||||||||
@Blocking | ||||||||||||||||||||||||||||
@Path("/_msearch") | ||||||||||||||||||||||||||||
public HttpResponse multiSearch(String postBody) throws Exception { | ||||||||||||||||||||||||||||
LOG.debug("Search request: {}", postBody); | ||||||||||||||||||||||||||||
public HttpResponse multiSearch(String postBody) { | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
CurrentTraceContext currentTraceContext = Tracing.current().currentTraceContext(); | ||||||||||||||||||||||||||||
try (var scope = new StructuredTaskScope<EsSearchResponse>()) { | ||||||||||||||||||||||||||||
List<StructuredTaskScope.Subtask<EsSearchResponse>> requestSubtasks = | ||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||
LOG.debug("Search request: {}", postBody); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
CurrentTraceContext currentTraceContext = Tracing.current().currentTraceContext(); | ||||||||||||||||||||||||||||
try (var scope = new StructuredTaskScope<EsSearchResponse>()) { | ||||||||||||||||||||||||||||
List<StructuredTaskScope.Subtask<EsSearchResponse>> requestSubtasks = | ||||||||||||||||||||||||||||
openSearchRequest.parseHttpPostBody(postBody).stream() | ||||||||||||||||||||||||||||
.map((request) -> scope.fork(currentTraceContext.wrap(() -> doSearch(request)))) | ||||||||||||||||||||||||||||
.toList(); | ||||||||||||||||||||||||||||
.map((request) -> scope.fork(currentTraceContext.wrap(() -> doSearch(request)))) | ||||||||||||||||||||||||||||
.toList(); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
scope.join(); | ||||||||||||||||||||||||||||
SearchResponseMetadata responseMetadata = | ||||||||||||||||||||||||||||
scope.join(); | ||||||||||||||||||||||||||||
SearchResponseMetadata responseMetadata = | ||||||||||||||||||||||||||||
new SearchResponseMetadata( | ||||||||||||||||||||||||||||
0, | ||||||||||||||||||||||||||||
requestSubtasks.stream().map(StructuredTaskScope.Subtask::get).toList(), | ||||||||||||||||||||||||||||
Map.of("traceId", getTraceId())); | ||||||||||||||||||||||||||||
return HttpResponse.of( | ||||||||||||||||||||||||||||
0, | ||||||||||||||||||||||||||||
requestSubtasks.stream().map(StructuredTaskScope.Subtask::get).toList(), | ||||||||||||||||||||||||||||
Map.of("traceId", getTraceId())); | ||||||||||||||||||||||||||||
return HttpResponse.of( | ||||||||||||||||||||||||||||
HttpStatus.OK, MediaType.JSON_UTF_8, JsonUtil.writeAsString(responseMetadata)); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} catch (Exception e) { | ||||||||||||||||||||||||||||
LOG.error("Error fulfilling request for multisearch query", e); | ||||||||||||||||||||||||||||
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. I believe we should already be logging these, as we've enabled Armeria request logging here: astra/astra/src/main/java/com/slack/astra/server/ArmeriaService.java Lines 72 to 84 in 2d7c87f
This should automatically log all successful and failed requests at the log levels indicated. This does make use of I'm not sure if this currently logs out the stack trace, but instead of adding try/catches to the individual endpoints I think that looking into the |
||||||||||||||||||||||||||||
return HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
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, this is a good add.