[SDK] Implementation of container resource as per semconv#3572
[SDK] Implementation of container resource as per semconv#3572lalitb merged 31 commits intoopen-telemetry:mainfrom
Conversation
|
|
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3572 +/- ##
==========================================
+ Coverage 90.03% 90.08% +0.06%
==========================================
Files 220 222 +2
Lines 7069 7115 +46
==========================================
+ Hits 6364 6409 +45
- Misses 705 706 +1
🚀 New features to boost your workflow:
|
…hilbhatia08/opentelemetry-cpp into implement_resource_detectors
|
Thanks for the PR @nikhilbhatia08! I think we just need to hash out how best to include these "built-in" detectors in the repo/build systems since many will bring platform dependencies. I've posted my proposal to the initial issue thread. |
hello changes some changes
…hilbhatia08/opentelemetry-cpp into implement_resource_detectors
There was a problem hiding this comment.
Pull Request Overview
This PR implements a container resource detector that extracts container IDs from cgroup information to comply with OpenTelemetry semantic conventions. The implementation focuses specifically on detecting the container.id attribute by parsing /proc/self/cgroup files.
- Adds a new
ContainerResourceDetectorclass that reads container ID from cgroup files - Implements helper functions for parsing container IDs from cgroup file lines using regex
- Adds comprehensive test coverage for container ID extraction logic
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| resource_detectors/include/opentelemetry/resource_detectors/container_resource_detector.h | Header file defining the ContainerResourceDetector class and helper functions |
| resource_detectors/container_detector.cc | Implementation of the ContainerResourceDetector::Detect() method |
| resource_detectors/container.cc | Implementation of container ID extraction logic from cgroup files |
| resource_detectors/CMakeLists.txt | CMake configuration for the new resource_detectors library |
| resource_detectors/BUILD | Bazel build configuration for the resource_detectors library |
| sdk/test/resource/resource_test.cc | Test cases for container ID extraction functionality |
| sdk/test/resource/CMakeLists.txt | Updated test dependencies to include resource_detectors |
| sdk/test/resource/BUILD | Updated Bazel test dependencies |
| sdk/src/resource/resource_detector.cc | Refactored environment variable constants to use constexpr |
| CMakeLists.txt | Added resource_detectors subdirectory to build |
resource_detectors/include/opentelemetry/resource_detectors/container_resource_detector.h
Outdated
Show resolved
Hide resolved
resource_detectors/include/opentelemetry/resource_detectors/container_resource_detector.h
Show resolved
Hide resolved
resource_detectors/include/opentelemetry/resource_detectors/container_resource_detector.h
Show resolved
Hide resolved
There was a problem hiding this comment.
LGTM, once preview flag is added and approved by @dbarker. Thanks @nikhilbhatia08 for contribution, nice work.
dbarker
left a comment
There was a problem hiding this comment.
Looks good! Thanks for the PR. Congrats on your first contribution! Looking forward to the next one :)
|
Thank you so much, @dbarker, @lalitb, and @rafaelroquetto, for helping me with my first contribution! Really appreciate it :) Looking forward to contributing more. |
Fixes # (issue)
Partially fixes #3548
Changes
Added container resource detector only for collecting info about
container.idfrom/proc/self/cgroupand added test coverage to it, but could not add test coverage toDetect()of ContainerResourcePlease provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes