-
Notifications
You must be signed in to change notification settings - Fork 823
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: Added AWS ECS Plugins Resource Detector #1404
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1404 +/- ##
==========================================
+ Coverage 93.11% 93.15% +0.04%
==========================================
Files 154 155 +1
Lines 4807 4839 +32
Branches 971 980 +9
==========================================
+ Hits 4476 4508 +32
Misses 331 331
|
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
Also, for the container ID attribute can be found in specification document: https://github.com/open-telemetry/opentelemetry-specification/tree/b338f9f63dbf02ff8ebd100e8a847e7bf43e2682/specification/resource/semantic_conventions#container |
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is grabbing the last 64 characters of the first valid (long-enough) line in /proc/self/cgroup
, to retrieve the container ID. While it appears the content in /proc/self/cgroup
has changed before (docker -> ecs) it seems unlikely future changes would break this approach anytime soon. And AWS folks would know much better than I would.
Did notice a few small things on the testing side for consideration.
}); | ||
|
||
sandbox.assert.calledOnce(hostStub); | ||
// sandbox.assert.calledOnce(readStub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray commented-out line.
hostStub = sandbox.stub(os, 'hostname').returns(hostNameData); | ||
readStub = sandbox | ||
.stub(AwsEcsDetector, 'readFileAsync' as any) | ||
.resolves(multiValidCgroupData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this actually tests what it says.
each of the lines in multiValidCgroupData
contain the same ID as the last 64 chars, so it doesn't necessarily prove it grabbed the first 'valid' (length > 64) one. it is minor, i can tell the code is working but perhaps a more accurate test would be to have the first line be 64 chars of a different/unexpected ID as well as having the last line be a valid, but unexpected ID to show you are grabbing the item that is expected (the middle one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in practice, multiple lines contain container ID in the same time. This testcase is to verify the logic here because we only grab the first valid container ID to reduce time cost.
I also think I can add an unexpected ID here. Thank you for pointing out!
}); | ||
|
||
sandbox.assert.calledOnce(hostStub); | ||
// sandbox.assert.calledOnce(readStub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray commented-out line.
@dyladan Hello Daniel. Today is almost the last day of internship. I really appreciate you reviewing and comments on all the PR and the instructions you gave me! Without you, I can never ensure the code quality and satisfy the standard of Typescript. Really Really appreciate it! |
BTW, since I am off-boarding, I am wondering when can this PR be merged? |
We're just waiting on one more @open-telemetry/javascript-approvers and it can be merged |
@open-telemetry/javascript-approvers Please take a look at this PR so it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Which problem is this PR solving?
Added AWS ECS plugins resource detector.
Short description of the changes
Explanation of this part can be referred to issue I opened: Add container ID attribute for Resource constants #1394
Since there is no response, I just add this part and made a PR.
If you would like to review @dyladan @anuraaga
Really appreciate it!
A Question for ECS and Beanstalk detector PRs
Since we have decided to put vendor's resource detector to js-contrib repository:
I am not so sure when will these code be moved to js-contrib and my internship has limited time to go.
May we first merge these PRs so we could move them together to js-contrib afterwards?