diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1acf515ea3..b149852a95 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -33,6 +33,25 @@ Notes: See the <> guide. +==== Unreleased + +[float] +===== Breaking changes + +[float] +===== Features + +- Minor improvement to container ID parsing from /etc/cgroup v1 files in + AWS ECS Fargate, where the pattern has been observed to sometimes differ + from the documented pattern. (https://github.com/elastic/apm/issues/888[APM spec issue #888]) + + +[float] +===== Bug fixes + +[float] +===== Chores + [[release-notes-4.7.3]] ==== 4.7.3 - 2024/08/09 diff --git a/lib/apm-client/http-apm-client/container-info.js b/lib/apm-client/http-apm-client/container-info.js index 58bd42383e..04dbbf89c5 100644 --- a/lib/apm-client/http-apm-client/container-info.js +++ b/lib/apm-client/http-apm-client/container-info.js @@ -12,7 +12,7 @@ const uuidSource = '[0-9a-f]{8}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{12}'; const containerSource = '[0-9a-f]{64}'; const taskSource = '[0-9a-f]{32}'; -const awsEcsSource = '[0-9a-f]{32}-[0-9]{10}'; +const awsEcsSource = '[0-9a-f]{32}-[0-9]{1,10}'; const lineReg = /^(\d+):([^:]*):(.+)$/; const podReg = new RegExp(`pod(${uuidSource})(?:.slice)?$`); diff --git a/test/apm-client/http-apm-client/container-info.test.js b/test/apm-client/http-apm-client/container-info.test.js index 9b6ca70838..938ac8502c 100644 --- a/test/apm-client/http-apm-client/container-info.test.js +++ b/test/apm-client/http-apm-client/container-info.test.js @@ -265,6 +265,48 @@ tape.test('basics', (t) => { }, ); + // https://github.com/elastic/apm/issues/888 Fewer than ten digits observed + // for the suffix in ECS Fargate in the wild. + t.deepEqual( + parse( + '1:name=systemd:/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-123456789', + // ^^^^^^^^^ + ), + { + entries: [ + { + id: '1', + groups: 'name=systemd', + path: '/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-123456789', + controllers: ['name=systemd'], + taskId: '46686c7c701cdfdf2549f88f7b9575e9', + }, + ], + containerId: + '34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376', + taskId: '46686c7c701cdfdf2549f88f7b9575e9', + }, + ); + t.deepEqual( + parse( + '1:name=systemd:/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-1', + ), + { + entries: [ + { + id: '1', + groups: 'name=systemd', + path: '/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-123456789', + controllers: ['name=systemd'], + taskId: '46686c7c701cdfdf2549f88f7b9575e9', + }, + ], + containerId: + '34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376', + taskId: '46686c7c701cdfdf2549f88f7b9575e9', + }, + ); + t.deepEqual( parse(` 12:devices:/user.slice