Skip to content

Commit

Permalink
Send early empty success response in OTelIngest to prevent timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Dec 4, 2024
1 parent 8d2cf50 commit 4029d72
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions OpenTelemetryIngest/API/OTelIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ router.post(
);
}

Response.sendEmptySuccessResponse(req, res); // send empty response to client early to avoid timeouts.

const traceData: JSONObject = req.body.toJSON
? req.body.toJSON()
: req.body;
Expand Down Expand Up @@ -408,8 +410,6 @@ router.post(
}).catch((err: Error) => {
logger.error(err);
});

return Response.sendEmptySuccessResponse(req, res);
} catch (err) {
return next(err);
}
Expand All @@ -432,6 +432,8 @@ router.post(
);
}

Response.sendEmptySuccessResponse(req, res); // send empty response to client early to avoid timeouts.

req.body = req.body.toJSON ? req.body.toJSON() : req.body;

const resourceMetrics: JSONArray = req.body[
Expand Down Expand Up @@ -687,8 +689,6 @@ router.post(
}).catch((err: Error) => {
logger.error(err);
});

return Response.sendEmptySuccessResponse(req, res);
} catch (err) {
return next(err);
}
Expand All @@ -711,6 +711,8 @@ router.post(
);
}

Response.sendEmptySuccessResponse(req, res); // send empty response to client early to avoid timeouts.

req.body = req.body.toJSON ? req.body.toJSON() : req.body;

const resourceLogs: JSONArray = req.body["resourceLogs"] as JSONArray;
Expand Down Expand Up @@ -912,8 +914,6 @@ router.post(
}).catch((err: Error) => {
logger.error(err);
});

return Response.sendEmptySuccessResponse(req, res);
} catch (err) {
return next(err);
}
Expand Down

0 comments on commit 4029d72

Please sign in to comment.