DataDog / java-dogstatsd-client

Java statsd client library
MIT License
176 stars 102 forks source link

[CONTINT-1132] Send in-<inode> using the cgroup controller when container-id cannot be retrieved #232

Closed AliDatadog closed 10 months ago

AliDatadog commented 10 months ago

Implementation of https://github.com/DataDog/datadog-go/pull/291 but in Java

This Pull Request implements the support of Origin Detection when the container-id is unavailable from inside the application container only with cgroupv2.

It first retrieves the cgroup node path by parsing proc/self/cgroup which is formatted differently depending on the cgroup version. See https://man7.org/linux/man-pages/man7/cgroups.7.html.

The format is a list of hierarchy-ID:controller-list:cgroup-path similar to:

0:: 1:name=systemd:... // only in cgroupv1 Once the path is retrieved, we retrieve the inode of /sys/fs/cgroup + + where is the path retrieved previously.

I am not sure how to create a dummy app that uses this library.

Test