Skip to content

Commit

Permalink
Merge pull request #211 from scality/dev/ft/pushMetricObjCopy
Browse files Browse the repository at this point in the history
FT: Push metrics for object copy
  • Loading branch information
vrancurel authored Sep 17, 2016
2 parents b410c76 + 17893dd commit d3ba43b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions lib/api/objectCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ function objectCopy(authInfo, request, sourceBucket,
logger.newRequestLoggerFromSerializedUids(
log.getSerializedUids()));
}
const sourceObjSize = storeMetadataParams.size;
const destObjPrevSize = destObjMD ?
destObjMD['content-length'] : null;
return next(null, storeMetadataParams,
serverSideEncryption);
serverSideEncryption, sourceObjSize, destObjPrevSize);
});
},
], (err, storeMetadataParams, serverSideEncryption) => {
], (err, storeMetadataParams, serverSideEncryption, sourceObjSize,
destObjPrevSize) => {
if (err) {
return callback(err);
}
Expand All @@ -304,6 +308,7 @@ function objectCopy(authInfo, request, sourceBucket,
// TODO: Add version headers for response
// (if source or destination is version).
// Add expiration header if lifecycle enabled
return callback(null, xml, additionalHeaders);
return callback(null, xml, additionalHeaders, sourceObjSize,
destObjPrevSize);
});
}
8 changes: 5 additions & 3 deletions lib/routes/routePUT.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ export default function routePUT(request, response, log, utapi) {
});
} else if (request.headers['x-amz-copy-source']) {
return api.callApiMethod('objectCopy', request, log, (err, xml,
additionalHeaders) =>
additionalHeaders, sourceObjSize, destObjPrevSize) => {
pushMetrics(err, log, utapi, 'objectCopy', sourceObjSize,
destObjPrevSize);
routesUtils.responseXMLBody(err, xml, response, log,
additionalHeaders)
);
additionalHeaders);
});
} else {
if (!request.headers['content-length']) {
return routesUtils.responseNoBody(errors.MissingContentLength,
Expand Down
4 changes: 4 additions & 0 deletions lib/utilities/pushMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function pushMetrics(err, log, utapi, action, resource,
utapi.pushMetricPutObject(reqUid, resource, contentLength,
prevContentLen);
break;
case 'objectCopy':
utapi.pushMetricCopyObject(reqUid, resource, contentLength,
prevContentLen);
break;
case 'bucketGetACL':
utapi.pushMetricGetBucketAcl(reqUid, resource);
break;
Expand Down

0 comments on commit d3ba43b

Please sign in to comment.