Skip to content

Commit

Permalink
chore(website,preprocessing): also log request ids when calling the b…
Browse files Browse the repository at this point in the history
…ackend
  • Loading branch information
fengelniederhammer committed Oct 15, 2024
1 parent 94f85c4 commit 69d9e39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions preprocessing/nextclade/src/loculus_preprocessing/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def fetch_unprocessed_sequences(
}
logging.debug(f"Requesting data with ETag: {etag}")
response = requests.post(url, data=params, headers=headers, timeout=10)
logging.info(
f"Unprocessed data from backend: status code {response.status_code}, request id: {response.headers.get('x-request-id')}")
match response.status_code:
case HTTPStatus.NOT_MODIFIED:
return etag, None
Expand Down Expand Up @@ -140,8 +142,8 @@ def submit_processed_sequences(
if not response.ok:
Path("failed_submission.json").write_text(ndjson_string, encoding="utf-8")
msg = (
f"Submitting processed data failed. Status code: {
response.status_code}\n"
f"Submitting processed data failed. Status code: {response.status_code}, "
f"request id: {response.headers.get('x-request-id')}\n"
f"Response: {response.text}\n"
f"Data sent in request: {ndjson_string[0:1000]}...\n"
)
Expand Down
11 changes: 9 additions & 2 deletions website/src/services/zodiosWrapperClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ export class ZodiosWrapperClient<Api extends ZodiosEndpointDefinitions> {

const message = error.message;
if (error.response !== undefined) {
const requestId =
error.response.headers['x-request-id'] !== undefined
? `(request id ${error.response.headers['x-request-id']}) `
: '';

let problemDetailResponse;
try {
problemDetailResponse = problemDetail.parse(this.tryToExtractProblemDetail(error.response));
} catch (e) {
this.logger.error(`Unknown error from ${this.serviceName}: ${JSON.stringify(error.response.data)}`);
this.logger.error(
`Unknown error from ${this.serviceName} ${requestId}: ${JSON.stringify(error.response.data)}`,
);
return {
type: 'about:blank',
title: error.message,
Expand All @@ -79,7 +86,7 @@ export class ZodiosWrapperClient<Api extends ZodiosEndpointDefinitions> {
};
}

this.logger.info(`${message}: ${problemDetailResponse.detail}`);
this.logger.info(`${requestId}${message}: ${problemDetailResponse.detail}`);
return problemDetailResponse;
}

Expand Down

0 comments on commit 69d9e39

Please sign in to comment.