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: add detector for container ID in cgroup v1 #515

Merged
merged 20 commits into from
Sep 16, 2022

Conversation

rauno56
Copy link
Contributor

@rauno56 rauno56 commented Jul 21, 2022

Description

This only works when cgroup v1 is used.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Internal change (a change which is not visible to the package consumers)
  • Documentation change or requires a documentation update

How Has This Been Tested?

  • Tested manually
  • Added automated tests

Checklist:

  • Unit tests have been added/updated
  • Documentation has been updated
  • Change file has been generated (npm run change:new)
  • Delete this branch (after the PR is merged)

@rauno56 rauno56 changed the title feat: add Cgroup v1 detector feat: add detector for container ID in cgroup v1 Jul 21, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2022

Codecov Report

Merging #515 (1a098cb) into main (a16441c) will decrease coverage by 0.47%.
The diff coverage is 73.07%.

@@            Coverage Diff             @@
##             main     #515      +/-   ##
==========================================
- Coverage   88.30%   87.83%   -0.48%     
==========================================
  Files          26       27       +1     
  Lines         804      830      +26     
  Branches      183      187       +4     
==========================================
+ Hits          710      729      +19     
- Misses         94      101       +7     
Impacted Files Coverage Δ
src/detectors/DockerCGroupV1Detector.ts 72.00% <72.00%> (ø)
src/resource.ts 88.88% <100.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a16441c...1a098cb. Read the comment docs.

@rauno56 rauno56 marked this pull request as ready for review July 25, 2022 09:52
@rauno56 rauno56 requested review from a team as code owners July 25, 2022 09:52
@rauno56
Copy link
Contributor Author

rauno56 commented Sep 8, 2022

@seemk, this is ready for another look. Matches Java(synced with Profiling PM about this) - best option for now.

The test failure seems unrelated. Let's see if that's just flaky - rerunning.

} catch (e) {
if (e instanceof Error) {
const errorMessage = e.message;
diag.info(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this mean logging this error on other platforms besides Linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with the current implementation it would. Your suggestion?

How about we detect the platform and only call _getContainerId() if it's linux?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the whole detector could check for process.platform === 'linux'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by "whole". Since it's currently the only platform-specific detector, added it into the detector itself. Once we have more, we could do it in resource.ts to optimize.

@rauno56
Copy link
Contributor Author

rauno56 commented Sep 14, 2022

@seemk, PTAL.

identifier for differentiating between containers.
It also matches Java: https://github.com/open-telemetry/opentelemetry-java/commit/2cb461d4aef16f1ac1c5e67edc2fb41f90ed96a3#diff-ad68bc34d4da31a50709591d4b7735f88c008be7ed1fc325c6367dd9df033452
*/
protected _parseFile(contents: string): string | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important / nit, but _parseFile does not actually parse a file, but a container id? 💭

@seemk seemk merged commit cc1ba3e into signalfx:main Sep 16, 2022
@seemk seemk mentioned this pull request Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants