Skip to content

Commit 01bc3c8

Browse files
trentmPeterEinberger
authored andcommitted
feat: container-info for AWS ECS/Fargate; [5s,1d] guard on central config re-fetch interval (elastic#3008)
Update elastic-apm-http-client to get these changes. This also drops using 'container-info' directly in this repo's tests. Given that the impl in that module and in the http-client might diverge over time, it isn't necessarily valid to use 'container-info' here. Closes: elastic#2914 Closes: elastic#2941
1 parent 32de70f commit 01bc3c8

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

CHANGELOG.asciidoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,28 @@ Notes:
3333
3434
==== Unreleased
3535
36-
* Enable support for redis v4 ({pull}2945[#2945])
37-
3836
[float]
3937
===== Breaking changes
4038
4139
[float]
4240
===== Features
4341
42+
* Enable support for redis v4 ({pull}2945[#2945])
43+
44+
* Improve container-info gathering to support AWS ECS/Fargate environments.
45+
({issues}2914[#2914])
46+
4447
[float]
4548
===== Bug fixes
4649
4750
[float]
4851
===== Chores
4952
53+
* Add guards to ensure that a crazy `Cache-Control: max-age=...` response
54+
header cannot accidentally result in inappropriate intervals for fetching
55+
central config. The re-fetch delay is clamped to `[5 seconds, 1 day]`.
56+
({issues}2941[#2941])
57+
5058
[[release-notes-3.39.0]]
5159
==== 3.39.0 2022/10/17
5260

package-lock.json

Lines changed: 7 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"basic-auth": "^2.0.1",
9292
"cookie": "^0.5.0",
9393
"core-util-is": "^1.0.2",
94-
"elastic-apm-http-client": "11.0.1",
94+
"elastic-apm-http-client": "11.0.2",
9595
"end-of-stream": "^1.4.4",
9696
"error-callsites": "^2.0.4",
9797
"error-stack-parser": "^2.0.6",
@@ -139,7 +139,6 @@
139139
"clone": "^2.0.0",
140140
"columnify": "^1.5.4",
141141
"connect": "^3.7.0",
142-
"container-info": "^1.0.1",
143142
"dashdash": "^2.0.0",
144143
"dependency-check": "^4.1.0",
145144
"diagnostics_channel": "^1.1.0",

test/agent.test.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var http = require('http')
1616
var path = require('path')
1717
var os = require('os')
1818

19-
var { sync: containerInfo } = require('container-info')
2019
var test = require('tape')
2120

2221
const Agent = require('../lib/agent')
@@ -26,8 +25,6 @@ const { MockAPMServer } = require('./_mock_apm_server')
2625
const { NoopTransport } = require('../lib/noop-transport')
2726
var packageJson = require('../package.json')
2827

29-
var inContainer = 'containerId' in (containerInfo() || {})
30-
3128
// Options to pass to `agent.start()` to turn off some default agent behavior
3229
// that is unhelpful for these tests.
3330
const agentOpts = {
@@ -57,19 +54,20 @@ function assertMetadata (t, payload) {
5754
t.deepEqual(payload.service.runtime, { name: 'node', version: process.versions.node }, 'metadata: service.runtime')
5855
t.deepEqual(payload.service.agent, { name: 'nodejs', version: packageJson.version }, 'metadata: service.agent')
5956

60-
const expectedSystemKeys = ['hostname', 'architecture', 'platform']
61-
if (inContainer) expectedSystemKeys.push('container')
62-
63-
t.deepEqual(Object.keys(payload.system), expectedSystemKeys, 'metadata: system')
64-
t.strictEqual(payload.system.hostname, os.hostname(), 'metadata: system.hostname')
65-
t.strictEqual(payload.system.architecture, process.arch, 'metadata: system.architecture')
66-
t.strictEqual(payload.system.platform, process.platform, 'metadata: system.platform')
67-
68-
if (inContainer) {
69-
t.deepEqual(Object.keys(payload.system.container), ['id'], 'metadata: system.container')
70-
t.strictEqual(typeof payload.system.container.id, 'string', 'metadata: system.container.id is a string')
71-
t.ok(/^[\da-f]{64}$/.test(payload.system.container.id), 'metadata: system.container.id')
57+
const system = Object.assign({}, payload.system)
58+
t.strictEqual(system.hostname, os.hostname(), 'metadata: system.hostname')
59+
delete system.hostname
60+
t.strictEqual(system.architecture, process.arch, 'metadata: system.architecture')
61+
delete system.architecture
62+
t.strictEqual(system.platform, process.platform, 'metadata: system.platform')
63+
delete system.platform
64+
if (system.container) {
65+
t.deepEqual(Object.keys(system.container), ['id'], 'metadata: system.container')
66+
t.strictEqual(typeof system.container.id, 'string', 'metadata: system.container.id is a string')
67+
t.ok(/^[\da-f]{64}$/.test(system.container.id), 'metadata: system.container.id')
68+
delete system.container
7269
}
70+
t.equal(Object.keys(system).length, 0, 'metadata: system, no unexpected keys: ' + JSON.stringify(system))
7371

7472
t.ok(payload.process, 'metadata: process')
7573
t.strictEqual(payload.process.pid, process.pid, 'metadata: process.pid')

0 commit comments

Comments
 (0)