Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: container ID detector for cgroup v2 #1181

Merged
merged 26 commits into from
Oct 1, 2022
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ad89334
added another block to test for v2
abhee11 Sep 4, 2022
37d45cb
feat: changing export name to reflect generic docker
abhee11 Sep 4, 2022
d933955
feat: adding geenric naming and logic changes to support cgroup v2
abhee11 Sep 15, 2022
4ad530d
test: test file renamed
abhee11 Sep 15, 2022
1ebd445
feat: adding hostname check
abhee11 Sep 16, 2022
5cd6324
feat: adding hostname check- refactor
abhee11 Sep 16, 2022
132e06d
feat: fixed a test and fixed lint
abhee11 Sep 19, 2022
0a61ba2
feat: added another condition to check for length
abhee11 Sep 19, 2022
9ad9f52
test: added two more tests
abhee11 Sep 19, 2022
ffcebb8
Merge pull request #1 from abhee11/docker-v2-detector
abhee11 Sep 19, 2022
432759b
Merge branch 'open-telemetry:main' into main
abhee11 Sep 19, 2022
5e626e9
feat: renamed docker to container and addressed pr comments
abhee11 Sep 20, 2022
5406466
feat: renamed docker to container and addressed pr comments- 2
abhee11 Sep 20, 2022
2c775d0
feat: renamed docker to container and addressed pr comments-3
abhee11 Sep 20, 2022
541b84a
Merge branch 'main' into main
abhee11 Sep 20, 2022
7813abe
feat: addressed pr comments-2
abhee11 Sep 22, 2022
74c362f
Merge branch 'main' of https://github.com/abhee11/opentelemetry-js-co…
abhee11 Sep 22, 2022
c3e2359
Merge branch 'main' into main
abhee11 Sep 22, 2022
3e3a20b
feat: modified tests to take in multiple lines input
abhee11 Sep 30, 2022
6740303
Merge branch 'main' of https://github.com/abhee11/opentelemetry-js-co…
abhee11 Sep 30, 2022
fc0f31c
feat: merge resolution for manifest
abhee11 Sep 30, 2022
e4ca980
Merge branch 'main' into main
abhee11 Sep 30, 2022
9ed5aa5
feat: fixing release please manifest
abhee11 Sep 30, 2022
5dee09c
feat: merge resolution for manifest
abhee11 Sep 30, 2022
a72a56f
feat: changing please-config to rename docker to container
abhee11 Sep 30, 2022
2c4d709
feat: replaced >= check to == check
abhee11 Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: fixed a test and fixed lint
abhee11 committed Sep 19, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 132e06db682df076ee5bf5df14d261cf3fdd6b2a
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ export class DockerDetector implements Detector {
readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup';
readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo';
readonly UTF8_UNICODE = 'utf8';
readonly HOSTNAME = "hostname";
readonly HOSTNAME = 'hostname';

private static readFileAsync = util.promisify(fs.readFile);

@@ -40,8 +40,8 @@ export class DockerDetector implements Detector {
return !containerId
? Resource.empty()
: new Resource({
[SemanticResourceAttributes.CONTAINER_ID]: containerId,
});
[SemanticResourceAttributes.CONTAINER_ID]: containerId,
});
} catch (e) {
diag.info(
'Docker Detector did not identify running inside a supported docker container, no docker attributes will be added to resource: ',
@@ -73,7 +73,7 @@ export class DockerDetector implements Detector {
splitData = rawData.trim().split('\n');
for (let str of splitData) {
if (str.includes(this.HOSTNAME)) {
str
str = str
.split('/')
.filter(s => s.length >= this.CONTAINER_ID_LENGTH)[0];
return str.substring(str.length - this.CONTAINER_ID_LENGTH);
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ describe('dockerCGroupV1Detector', () => {
const resource: Resource = await dockerDetector.detect();
assert.deepStrictEqual(resource.attributes, {});

sinon.assert.calledOnce(readStub);
sinon.assert.calledTwice(readStub);
assert.ok(resource);
});