DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
611 stars 302 forks source link

Support inode resolution mechanism for Origin Detection #813

Closed wdhif closed 8 months ago

wdhif commented 8 months ago

Requirements for Contributing to this repository

What does this PR do?

Implements the support of Origin Detection when the container ID is unavailable from inside the container by using the inode resolution mechanic. The original Go implementation is here: https://github.com/DataDog/datadog-go/pull/291

Description of the Change

If we are not able to find the container ID from inside the container, we will send instead the cgroup inode to be able to resolve the container ID on the Agent side.

Alternate Designs

Possible Drawbacks

Verification Process

Use the following deployment on a k8s cluster running cgroupv2:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dummy-dsd-python-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dummy-dsd-python-app
  template:
    metadata:
      labels:
        app: dummy-dsd-python-app
        admission.datadoghq.com/enabled: "false"
    spec:
      containers:
      - name: dummy-dsd-python-app
        image: wdhifdatadog/dummy-dsd-python-app
        imagePullPolicy: Always
        env:
        - name: DD_AGENT_HOST
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP

You should then be able to find a dummy.dsd.python.metric with a container_id tag.

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)