Skip to content

Commit e103919

Browse files
committed
CLDSRV-894: Report turn-around time for PutObject and UploadPart
Server access logs reported turn-around time as '-' for PutObject and UploadPart while all other operations reported it correctly. AWS reports turn-around time for these operations.
1 parent 029b436 commit e103919

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/api/api.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ const api = {
263263
request.serverAccessLog.analyticsUserName = authNames.userName;
264264
}
265265
if (apiMethod === 'objectPut' || apiMethod === 'objectPutPart') {
266+
request.on('end', () => {
267+
if (request.serverAccessLog) {
268+
request.serverAccessLog.startTurnAroundTime = process.hrtime.bigint();
269+
}
270+
});
266271
return next(null, userInfo, authorizationResults, streamingV4Params, infos);
267272
}
268273
// issue 100 Continue to the client

tests/unit/api/api.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ describe('api.callApiMethod', () => {
115115
api.callApiMethod('multipartDelete', request, response, log);
116116
});
117117

118+
['objectPut', 'objectPutPart'].forEach(method => {
119+
it(`should set startTurnAroundTime on request end for ${method}`, done => {
120+
sandbox.stub(api, method).callsFake(
121+
(userInfo, _request, streamingV4Params, _log, cb) => {
122+
request.on('end', () => {
123+
assert.strictEqual(typeof request.serverAccessLog.startTurnAroundTime, 'bigint');
124+
cb();
125+
});
126+
request.resume();
127+
});
128+
request.objectKey = 'testobject';
129+
request.serverAccessLog = {};
130+
api.callApiMethod(method, request, response, log, err => {
131+
assert.ifError(err);
132+
done();
133+
});
134+
});
135+
});
136+
118137
describe('MD5 checksum validation', () => {
119138
const methodsWithChecksumValidation = [
120139
'bucketPutACL',

0 commit comments

Comments
 (0)