Compare commits
2 Commits
ea3fff30b8
...
bc1feb0bc1
Author | SHA1 | Date |
---|---|---|
Taylor McKinnon | bc1feb0bc1 | |
Taylor McKinnon | 800b68dbe5 |
|
@ -99,6 +99,18 @@ const metricObj = {
|
|||
users: 'userId',
|
||||
};
|
||||
|
||||
const converters = {
|
||||
_genericPushMetric: '_convertParamsGenericPushMetric',
|
||||
_pushMetricDeleteMarkerObject: '_convertParamsGenericPushMetric',
|
||||
_pushMetricListBucketMultipartUploads: '_convertParamsGenericPushMetric',
|
||||
_pushMetricDeleteBucket: '_convertParamsGenericPushMetric',
|
||||
_pushMetricGetObject: '_convertParamsPushMetricGetObject',
|
||||
_genericPushMetricPutObject: '_convertGenericPushMetricPutObject',
|
||||
_genericPushMetricDeleteObject: '_convertGenericPushMetricDeleteObject',
|
||||
_pushMetricCompleteMultipartUpload: '_convertPushMetricCompleteMultipartUpload',
|
||||
_genericPushMetricUploadPart: '_convertGenericPushMetricUploadPart',
|
||||
};
|
||||
|
||||
class UtapiClient {
|
||||
/**
|
||||
* Create a UtapiClient
|
||||
|
@ -420,6 +432,11 @@ class UtapiClient {
|
|||
return callback();
|
||||
}
|
||||
|
||||
pushMetricV2(metric, reqUid, params, cb) {
|
||||
const convertedParams = this[converters[methods[metric].method]](params);
|
||||
return this.pushMetric(metric, reqUid, convertedParams, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates counter for the given action
|
||||
* @param {object} params - params for the metrics
|
||||
|
@ -1139,6 +1156,51 @@ class UtapiClient {
|
|||
return callback(null, res);
|
||||
});
|
||||
}
|
||||
|
||||
_convertParamsGenericPushMetric(params) {
|
||||
return params;
|
||||
}
|
||||
|
||||
_convertParamsPushMetricGetObject(params) {
|
||||
return {
|
||||
// newByteLength used as value for outgoingBytes
|
||||
newByteLength: params.outgoingBytes,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
_convertGenericPushMetricPutObject(params) {
|
||||
return {
|
||||
newByteLength: params.incomingBytes,
|
||||
oldByteLength: !params.objectDelta ? params.incomingBytes - params.sizeDelta : null,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
_convertGenericPushMetricDeleteObject(params) {
|
||||
return {
|
||||
byteLength: (params.storageDelta || 0) * -1,
|
||||
numberOfObjects: (params.objectDelta || 0) * -1,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
_convertPushMetricCompleteMultipartUpload(params) {
|
||||
return {
|
||||
oldByteLength: !params.objectDelta ? params.sizeDelta * -1 : null,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
_convertGenericPushMetricUploadPart(params) {
|
||||
return {
|
||||
newByteLength: params.incomingBytes,
|
||||
oldByteLength: !params.objectDelta ? params.incomingBytes - params.sizeDelta : null,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = UtapiClient;
|
||||
|
||||
|
|
Loading…
Reference in New Issue