Skip to content

Commit 1d8c571

Browse files
trentmdavid-luna
authored andcommitted
feat: improved container-id parsing for ECS Fargate (#4216)
Refs: elastic/apm#888 Closes: #4215
1 parent 6d00acb commit 1d8c571

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

CHANGELOG.asciidoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ Notes:
3333
3434
See the <<upgrade-to-v4>> guide.
3535
36+
==== Unreleased
37+
38+
[float]
39+
===== Breaking changes
40+
41+
[float]
42+
===== Features
43+
44+
- Minor improvement to container ID parsing from /etc/cgroup v1 files in
45+
AWS ECS Fargate, where the pattern has been observed to sometimes differ
46+
from the documented pattern. (https://github.com/elastic/apm/issues/888[APM spec issue #888])
47+
48+
49+
[float]
50+
===== Bug fixes
51+
52+
[float]
53+
===== Chores
54+
3655
3756
[[release-notes-4.7.3]]
3857
==== 4.7.3 - 2024/08/09

lib/apm-client/http-apm-client/container-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const uuidSource =
1212
'[0-9a-f]{8}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{12}';
1313
const containerSource = '[0-9a-f]{64}';
1414
const taskSource = '[0-9a-f]{32}';
15-
const awsEcsSource = '[0-9a-f]{32}-[0-9]{10}';
15+
const awsEcsSource = '[0-9a-f]{32}-[0-9]{1,10}';
1616

1717
const lineReg = /^(\d+):([^:]*):(.+)$/;
1818
const podReg = new RegExp(`pod(${uuidSource})(?:.slice)?$`);

test/apm-client/http-apm-client/container-info.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,48 @@ tape.test('basics', (t) => {
265265
},
266266
);
267267

268+
// https://github.com/elastic/apm/issues/888 Fewer than ten digits observed
269+
// for the suffix in ECS Fargate in the wild.
270+
t.deepEqual(
271+
parse(
272+
'1:name=systemd:/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-123456789',
273+
// ^^^^^^^^^
274+
),
275+
{
276+
entries: [
277+
{
278+
id: '1',
279+
groups: 'name=systemd',
280+
path: '/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-123456789',
281+
controllers: ['name=systemd'],
282+
taskId: '46686c7c701cdfdf2549f88f7b9575e9',
283+
},
284+
],
285+
containerId:
286+
'34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376',
287+
taskId: '46686c7c701cdfdf2549f88f7b9575e9',
288+
},
289+
);
290+
t.deepEqual(
291+
parse(
292+
'1:name=systemd:/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-1',
293+
),
294+
{
295+
entries: [
296+
{
297+
id: '1',
298+
groups: 'name=systemd',
299+
path: '/ecs/46686c7c701cdfdf2549f88f7b9575e9/46686c7c701cdfdf2549f88f7b9575e9-1',
300+
controllers: ['name=systemd'],
301+
taskId: '46686c7c701cdfdf2549f88f7b9575e9',
302+
},
303+
],
304+
containerId:
305+
'34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376',
306+
taskId: '46686c7c701cdfdf2549f88f7b9575e9',
307+
},
308+
);
309+
268310
t.deepEqual(
269311
parse(`
270312
12:devices:/user.slice

0 commit comments

Comments
 (0)