Skip to content

Commit

Permalink
feat(internal): update Entity ID to new format ci-
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Jan 28, 2025
1 parent 599da51 commit d64e06c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
// containerID is the containerID read at init from /proc/self/cgroup
containerID string

// entityID is the entityID to use for the container. It is the `cid-<containerID>` if the container id available,
// entityID is the entityID to use for the container. It is the `ci-<containerID>` if the container id available,
// otherwise the cgroup node controller's inode prefixed with `in-` or an empty string on incompatible OS.
// We use the memory controller on cgroupv1 and the root cgroup on cgroupv2.
entityID string
Expand Down Expand Up @@ -151,7 +151,7 @@ func readEntityID(mountPath, cgroupPath string, isHostCgroupNamespace bool) stri
// First try to emit the containerID if available. It will be retrieved if the container is
// running in the host cgroup namespace, independently of the cgroup version.
if containerID != "" {
return "cid-" + containerID
return "ci-" + containerID
}
// Rely on the inode if we're not running in the host cgroup namespace.
if isHostCgroupNamespace {
Expand All @@ -161,7 +161,7 @@ func readEntityID(mountPath, cgroupPath string, isHostCgroupNamespace bool) stri
}

// EntityID attempts to return the container ID or the cgroup node controller's inode if the container ID
// is not available. The cid is prefixed with `cid-` and the inode with `in-`.
// is not available. The cid is prefixed with `ci-` and the inode with `in-`.
func EntityID() string {
return entityID
}
Expand Down
2 changes: 1 addition & 1 deletion internal/container_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestReadEntityIDPrioritizeCID(t *testing.T) {

containerID = "fakeContainerID"
eid := readEntityID("", "", true)
assert.Equal(t, "cid-fakeContainerID", eid)
assert.Equal(t, "ci-fakeContainerID", eid)
}

func TestReadEntityIDFallbackOnInode(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/container_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ContainerID() string {
}

// EntityID attempts to return the container ID or the cgroup v2 node inode if the container ID is not available.
// The cid is prefixed with `cid-` and the inode with `in-`.
// The cid is prefixed with `ci-` and the inode with `in-`.
func EntityID() string {
return ""
}

0 comments on commit d64e06c

Please sign in to comment.