Skip to content

Commit a4f17bb

Browse files
committed
Merge branch 'improvement/CLDSRV-838' into q/9.2
2 parents 00c52d9 + 0f24499 commit a4f17bb

File tree

4 files changed

+5
-58
lines changed

4 files changed

+5
-58
lines changed

lib/utilities/serverAccessLogger.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,6 @@ function calculateElapsedMS(startTime, onCloseEndTime) {
386386
return Number(onCloseEndTime - startTime) / 1_000_000;
387387
}
388388

389-
function timestampToDateTime643(unixMS) {
390-
if (unixMS === undefined || unixMS === null) {
391-
return null;
392-
}
393-
394-
// clickhouse DateTime64(3) expects "seconds.milliseconds" (string type).
395-
return (unixMS / 1000).toFixed(3);
396-
}
397-
398389
function logServerAccess(req, res) {
399390
if (!req.serverAccessLog || !res.serverAccessLog || !serverAccessLogger) {
400391
return;
@@ -429,7 +420,7 @@ function logServerAccess(req, res) {
429420
elapsed_ms: calculateElapsedMS(params.startTime, params.onCloseEndTime) ?? undefined,
430421
431422
// AWS access server logs fields https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html
432-
startTime: timestampToDateTime643(params.startTimeUnixMS) ?? undefined, // AWS "Time" field
423+
startTime: params.startTimeUnixMS ?? undefined, // AWS "Time" field - milliseconds since epoch
433424
requester: getRequester(authInfo) ?? undefined,
434425
operation: getOperation(req),
435426
requestURI: getURI(req) ?? undefined,
@@ -489,5 +480,4 @@ module.exports = {
489480
getBytesSent,
490481
calculateTotalTime,
491482
calculateTurnAroundTime,
492-
timestampToDateTime643,
493483
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenko/cloudserver",
3-
"version": "9.2.18",
3+
"version": "9.2.19",
44
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
55
"main": "index.js",
66
"engines": {

schema/server_access_log.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
"minimum": 0
6363
},
6464
"startTime": {
65-
"description": "Timestamp formatted as: 'seconds.milliseconds', recorded when the server first routes the request. Represents the AWS server access log 'Time' field. String type compatible with Clickhouse DateTime64(3) type.",
66-
"type": "string"
65+
"description": "Milliseconds since Unix epoch, recorded when the server first routes the request. Represents the AWS server access log 'Time' field.",
66+
"type": "number"
6767
},
6868
"requester": {
6969
"description": "AWS server access log 'Requester' field. From AWS 'The canonical user ID of the requester, or a - for unauthenticated requests. If the requester was an IAM user, this field returns the requester's IAM user name along with the AWS account that the IAM user belongs to. This identifier is the same one used for access control purposes.'. We don't use null instead of '-' when the requester is missing.",

tests/unit/utils/serverAccessLogger.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const {
1111
getBytesSent,
1212
calculateTotalTime,
1313
calculateTurnAroundTime,
14-
timestampToDateTime643,
1514
} = require('../../../lib/utilities/serverAccessLogger');
1615

1716
describe('serverAccessLogger utility functions', () => {
@@ -680,48 +679,6 @@ describe('serverAccessLogger utility functions', () => {
680679
});
681680
});
682681

683-
describe('timestampToDateTime643', () => {
684-
it('should convert milliseconds to seconds with 3 decimal places', () => {
685-
const startTimeUnixMS = 1234567890000;
686-
const result = timestampToDateTime643(startTimeUnixMS);
687-
assert.strictEqual(result, '1234567890.000');
688-
});
689-
690-
it('should handle timestamp with milliseconds', () => {
691-
const startTimeUnixMS = 1234567890123;
692-
const result = timestampToDateTime643(startTimeUnixMS);
693-
assert.strictEqual(result, '1234567890.123');
694-
});
695-
696-
it('should handle 0', () => {
697-
const startTimeUnixMS = 0;
698-
const result = timestampToDateTime643(startTimeUnixMS);
699-
assert.strictEqual(result, '0.000');
700-
});
701-
702-
it('should return null when startTimeUnixMS is null', () => {
703-
const result = timestampToDateTime643(null);
704-
assert.strictEqual(result, null);
705-
});
706-
707-
it('should return null when startTimeUnixMS is undefined', () => {
708-
const result = timestampToDateTime643(undefined);
709-
assert.strictEqual(result, null);
710-
});
711-
712-
it('should handle small timestamps', () => {
713-
const startTimeUnixMS = 1000;
714-
const result = timestampToDateTime643(startTimeUnixMS);
715-
assert.strictEqual(result, '1.000');
716-
});
717-
718-
it('should handle timestamps with partial milliseconds', () => {
719-
const startTimeUnixMS = 1500;
720-
const result = timestampToDateTime643(startTimeUnixMS);
721-
assert.strictEqual(result, '1.500');
722-
});
723-
});
724-
725682
describe('logServerAccess', () => {
726683
let mockLogger;
727684
let sandbox;
@@ -874,7 +831,7 @@ describe('serverAccessLogger utility functions', () => {
874831
assert.strictEqual(loggedData.elapsed_ms, 20.5);
875832

876833
// Verify AWS access server log fields
877-
assert.strictEqual(loggedData.startTime, '1234567890.000');
834+
assert.strictEqual(loggedData.startTime, 1234567890000);
878835
assert.strictEqual(loggedData.requester, 'canonical123');
879836
assert.strictEqual(loggedData.operation, 'REST.GET.OBJECT');
880837
assert.strictEqual(loggedData.requestURI, 'GET /test-bucket/test-key.txt HTTP/1.1');

0 commit comments

Comments
 (0)