diff --git a/src/OpenTelemetry.Resources.Container/ContainerDetector.cs b/src/OpenTelemetry.Resources.Container/ContainerDetector.cs index 8955e85c4a..d7174e1b43 100644 --- a/src/OpenTelemetry.Resources.Container/ContainerDetector.cs +++ b/src/OpenTelemetry.Resources.Container/ContainerDetector.cs @@ -199,7 +199,7 @@ private static string RemovePrefixAndSuffixIfNeeded(string input, int startIndex using var httpClientHandler = ServerCertificateValidationHandler.Create(K8sCertificatePath, ContainerResourceEventSource.Log); var response = ResourceDetectorUtils.SendOutRequest(url, "GET", new KeyValuePair("Authorization", credentials), httpClientHandler).GetAwaiter().GetResult(); - var pod = DeserializeK8sResponse(response); + var pod = ResourceDetectorUtils.DeserializeFromString(response, SourceGenerationContext.Default.K8sPod); if (pod?.Status?.ContainerStatuses == null) { return null; @@ -221,14 +221,5 @@ private static string RemovePrefixAndSuffixIfNeeded(string input, int startIndex } return null; - - static K8sPod? DeserializeK8sResponse(string response) - { -#if NET6_0_OR_GREATER - return ResourceDetectorUtils.DeserializeFromString(response, SourceGenerationContext.Default.K8sPod); -#else - return ResourceDetectorUtils.DeserializeFromString(response); -#endif - } } }