-
Notifications
You must be signed in to change notification settings - Fork 588
fix(detector-aws): extract full container ID from ECS Fargate cgroup #2855
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
base: main
Are you sure you want to change the base?
fix(detector-aws): extract full container ID from ECS Fargate cgroup #2855
Conversation
@seongpil0948 looks like this PR is in draft, is this intentional? 🤔 |
i'm sorry to late .. 🫡 |
There has been a re-organization of the packages in this repository, see #2928 Would you mind to sync your PR with main branch? |
Looks like this needs reviews. The conflicts are just from package naming. @jj22ee can you please take a look? |
i worked on a new branch based on new structured packages |
a84117b
to
f3db796
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2855 +/- ##
==========================================
+ Coverage 89.02% 89.09% +0.06%
==========================================
Files 188 188
Lines 9223 9251 +28
Branches 1900 1909 +9
==========================================
+ Hits 8211 8242 +31
+ Misses 1012 1009 -3
🚀 New features to boost your workflow:
|
Refactored test suite to align with existing code style: - Added helper functions to reduce code duplication - Improved test organization and descriptions - Extracted common constants - Maintained all test functionality while improving readability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Hi @seongpil0948, wondering why not opt to use a more automated regex based approach (as mentioned in the issue, something like in DataDog/dd-trace-js#1176, which is now here)? IMO that would help alleviate some of the burden in the current PR which adds logic to "track and remove known prefixes", execute step-by-step extraction+sanitizing of the lastSegment, and perform two sanity validations based on the length of the extracted segment based on what we think is reasonable. Regex would be more "straight to the point" at a glance, easier to maintain. |
…paths Fixes container ID extraction for the new AWS ECS Fargate cgroup format (/ecs/<taskId>/<taskId>-<containerId>) by implementing regex-based pattern matching instead of manual string parsing. Changes: - Add _extractContainerIdFromLine() method with ECS-specific regex pattern - Maintain backward compatibility with legacy 64-character container IDs - Add comprehensive tests for new format and backward compatibility Fixes open-telemetry#2455 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Which problem is this PR solving?
AWS ECS Fargate changed their cgroup naming convention to
/ecs/<taskId>/<taskId>-<containerId>
format. The existing container ID extraction logic only takes the last 64 characters, causing truncation in the middle of the taskId and resulting in incomplete container IDs like438aa1824ca4058bdcab/c23e5f76c09d438aa1824ca4058bdcab-1234678
instead of the expected fullc23e5f76c09d438aa1824ca4058bdcab-1234678
.This breaks compatibility with observability vendors like DataDog that require the complete
taskId-containerId
format for proper container identification.Short description of the changes
_extractContainerIdFromLine()
method: Handles various container runtime formats (Docker, containerd, CRI-O) with proper prefix/suffix removal[a-zA-Z0-9\-_]+
to support real-world container ID formatsSupported formats:
/ecs/<taskId>/<taskId>-<containerId>
→taskId-containerId
/docker/containerid.scope
→containerid
system.slice:cri-containerd:containerid
→containerid
/uuid/34dc0b5e-626f-2c5c-4c51-70e34b10e765
→34dc0b5e-626f-2c5c-4c51-70e34b10e765
Fixes #2455