Skip to content

Commit

Permalink
Try removing xray checks
Browse files Browse the repository at this point in the history
Signed-off-by: cosa65 <[email protected]>
  • Loading branch information
cosa65 committed Aug 10, 2023
1 parent 2117baa commit 13b4777
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
6 changes: 1 addition & 5 deletions src/api.v2/events/handleWorkRequest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const AWSXRay = require('aws-xray-sdk');
const getLogger = require('../../utils/getLogger');

const logger = getLogger();
const validateAndSubmitWork = require('./validateAndSubmitWork');
const { authenticationMiddlewareSocketIO, authorize } = require('../middlewares/authMiddlewares');

const handleWorkRequest = async (socket, data, xraySegment) => {
const handleWorkRequest = async (socket, data) => {
const { uuid, Authorization, experimentId } = data;

try {
Expand All @@ -21,21 +20,18 @@ const handleWorkRequest = async (socket, data, xraySegment) => {
socket.emit(`WorkerInfo-${experimentId}`, {
response: {
podInfo,
trace: AWSXRay.getSegment().trace_id,
},
});
} catch (e) {
logger.log(`[REQ ??, SOCKET ${socket.id}] Error while processing WorkRequest event.`);
logger.trace(e);
xraySegment.addError(e);

socket.emit(`WorkResponse-${uuid}`, {
request: { ...data },
results: [],
response: {
cacheable: false,
error: e.message,
trace: AWSXRay.getSegment().trace_id,
},
});

Expand Down
32 changes: 1 addition & 31 deletions src/api.v2/events/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,7 @@
const AWSXRay = require('aws-xray-sdk');
const handleWorkRequest = require('./handleWorkRequest');
const getLogger = require('../../utils/getLogger');
const config = require('../../config');

const logger = getLogger();

module.exports = (socket) => {
socket.on('WorkRequest-v2', (data) => {
const segment = new AWSXRay.Segment(`API-${config.clusterEnv}-${config.sandboxId}`);
const ns = AWSXRay.getNamespace();

ns.runPromise(async () => {
AWSXRay.capturePromise();
AWSXRay.setSegment(segment);

logger.log(`[REQ ??, SOCKET ${socket.id}] Work submitted from client.`);
logger.log(`[REQ ??, SOCKET ${socket.id}] ${JSON.stringify(data, null, 2)}`);

const { experimentId } = data;
segment.addMetadata('request', data);
segment.addAnnotation('podName', config.podName);
segment.addAnnotation('sandboxId', config.sandboxId);
segment.addAnnotation('experimentId', experimentId);

segment.addIncomingRequestData({
request: {
method: 'POST',
url: `socketio://api-${config.sandboxId}-${config.clusterEnv}/${experimentId}/WorkRequest`,
},
});
await handleWorkRequest(socket, data, segment);

segment.close();
});
handleWorkRequest(socket, data);
});
};

0 comments on commit 13b4777

Please sign in to comment.