diff --git a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs index 402de38c0ee..13ec409906e 100644 --- a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs +++ b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs @@ -314,12 +314,6 @@ public void SelfDiagnosticsFileCreateException(string logDirectory, string excep this.WriteEvent(26, logDirectory, exception); } - [Event(27, Message = "Failed to create resource from ResourceDetector: '{0}' due to '{1}'.", Level = EventLevel.Warning)] - public void ResourceDetectorFailed(string resourceDetector, string issue) - { - this.WriteEvent(27, resourceDetector, issue); - } - [Event(28, Message = "Unknown error in TracerProvider '{0}': '{1}'.", Level = EventLevel.Error)] public void TracerProviderException(string evnt, string ex) { diff --git a/src/OpenTelemetry/Resources/OtelEnvResourceDetector.cs b/src/OpenTelemetry/Resources/OtelEnvResourceDetector.cs index a84e23cf721..fd78b3eba4f 100644 --- a/src/OpenTelemetry/Resources/OtelEnvResourceDetector.cs +++ b/src/OpenTelemetry/Resources/OtelEnvResourceDetector.cs @@ -15,7 +15,6 @@ // using System.Collections.Generic; -using System.Security; using OpenTelemetry.Internal; namespace OpenTelemetry.Resources @@ -30,17 +29,10 @@ public Resource Detect() { var resource = Resource.Empty; - try + if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) { - if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) - { - var attributes = ParseResourceAttributes(envResourceAttributeValue); - resource = new Resource(attributes); - } - } - catch (SecurityException ex) - { - OpenTelemetrySdkEventSource.Log.ResourceDetectorFailed(nameof(OtelEnvResourceDetector), ex.Message); + var attributes = ParseResourceAttributes(envResourceAttributeValue); + resource = new Resource(attributes); } return resource; diff --git a/src/OpenTelemetry/Resources/OtelServiceNameEnvVarDetector.cs b/src/OpenTelemetry/Resources/OtelServiceNameEnvVarDetector.cs index ff05610697a..5233f2004a4 100644 --- a/src/OpenTelemetry/Resources/OtelServiceNameEnvVarDetector.cs +++ b/src/OpenTelemetry/Resources/OtelServiceNameEnvVarDetector.cs @@ -15,7 +15,6 @@ // using System.Collections.Generic; -using System.Security; using OpenTelemetry.Internal; namespace OpenTelemetry.Resources @@ -28,19 +27,12 @@ public Resource Detect() { var resource = Resource.Empty; - try + if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) { - if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) + resource = new Resource(new Dictionary { - resource = new Resource(new Dictionary - { - [ResourceSemanticConventions.AttributeServiceName] = envResourceAttributeValue, - }); - } - } - catch (SecurityException ex) - { - OpenTelemetrySdkEventSource.Log.ResourceDetectorFailed(nameof(OtelServiceNameEnvVarDetector), ex.Message); + [ResourceSemanticConventions.AttributeServiceName] = envResourceAttributeValue, + }); } return resource;