From 5442c3ff74576dc61e313178ffcd452726631122 Mon Sep 17 00:00:00 2001 From: joegoldman2 <147369450+joegoldman@users.noreply.github.com> Date: Thu, 6 Jun 2024 06:56:51 +0000 Subject: [PATCH] Simplify deserialization --- .../ContainerDetector.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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 - } } }