You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Fix ContainerID detector on systemd with colon in cgroup path (#4449)
Co-authored-by: David Ashpole <dashpole@google.com>
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							3f74d77436
						
					
				
				
					commit
					71d13ffc2a
				
			| @@ -280,6 +280,7 @@ This release drops the compatibility guarantee of [Go 1.19]. | ||||
| - Do not append `_total` if the counter already has that suffix for the Prometheus exproter in `go.opentelemetry.io/otel/exporter/prometheus`. (#4373) | ||||
| - Fix resource detection data race in `go.opentelemetry.io/otel/sdk/resource`. (#4409) | ||||
| - Use the first-seen instrument name during instrument name conflicts in `go.opentelemetry.io/otel/sdk/metric`. (#4428) | ||||
| - Fix `ContainerID` resource detection on systemd when cgroup path has a colon. (#4449) | ||||
|  | ||||
| ### Deprecated | ||||
|  | ||||
|   | ||||
| @@ -29,7 +29,7 @@ type containerIDProvider func() (string, error) | ||||
|  | ||||
| var ( | ||||
| 	containerID         containerIDProvider = getContainerIDFromCGroup | ||||
| 	cgroupContainerIDRe                     = regexp.MustCompile(`^.*/(?:.*-)?([0-9a-f]+)(?:\.|\s*$)`) | ||||
| 	cgroupContainerIDRe                     = regexp.MustCompile(`^.*/(?:.*[-:])?([0-9a-f]+)(?:\.|\s*$)`) | ||||
| ) | ||||
|  | ||||
| type cgroupContainerIDDetector struct{} | ||||
|   | ||||
| @@ -62,6 +62,11 @@ func TestGetContainerIDFromLine(t *testing.T) { | ||||
| 			line:                " 13:name=systemd:/pod/d86d75589bf6cc254f3e2cc29debdf85dde404998aa128997a819ff991827356 ", | ||||
| 			expectedContainerID: "d86d75589bf6cc254f3e2cc29debdf85dde404998aa128997a819ff991827356", | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:                "with colon", | ||||
| 			line:                " 13:name=systemd:/kuberuntime/containerd/kubepods-pod872d2066_00ef_48ea_a7d8_51b18b72d739:cri-containerd:e857a4bf05a69080a759574949d7a0e69572e27647800fa7faff6a05a8332aa1", | ||||
| 			expectedContainerID: "e857a4bf05a69080a759574949d7a0e69572e27647800fa7faff6a05a8332aa1", | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: "invalid hex string", | ||||
| 			line: "13:name=systemd:/podruntime/docker/kubepods/ac679f8a8319c8cf7d38e1adf263bc08d23zzzz", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user