Skip to content

Commit c4a56e0

Browse files
authored
[ResourceDetector.AWS] Fixed Exception error while logging exceptions (open-telemetry#2451)
1 parent d87ce66 commit c4a56e0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/OpenTelemetry.Resources.AWS/AWSResourcesEventSource.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ public void ResourceAttributesExtractException(string format, Exception ex)
2626
}
2727
}
2828

29-
[Event(EventIdFailedToExtractAttributes, Message = "Failed to extract resource attributes in '{0}'.", Level = EventLevel.Warning)]
29+
[NonEvent]
30+
public void FailedToCreateHttpHandler(Exception exception)
31+
{
32+
if (this.IsEnabled(EventLevel.Warning, (EventKeywords)(-1)))
33+
{
34+
this.FailedToCreateHttpHandler(exception.ToInvariantString());
35+
}
36+
}
37+
38+
[Event(EventIdFailedToExtractAttributes, Message = "Failed to extract resource attributes in '{0}'. Error Message: '{1}'", Level = EventLevel.Warning)]
3039
public void FailedToExtractResourceAttributes(string format, string exception)
3140
{
3241
this.WriteEvent(EventIdFailedToExtractAttributes, format, exception);
@@ -39,9 +48,9 @@ public void FailedToValidateCertificate(string error)
3948
}
4049

4150
[Event(EventIdFailedToCreateHttpHandler, Message = "Failed to create HTTP handler. Exception: '{0}'", Level = EventLevel.Warning)]
42-
public void FailedToCreateHttpHandler(Exception exception)
51+
public void FailedToCreateHttpHandler(string error)
4352
{
44-
this.WriteEvent(EventIdFailedToCreateHttpHandler, exception.ToInvariantString());
53+
this.WriteEvent(EventIdFailedToCreateHttpHandler, error);
4554
}
4655

4756
[Event(EventIdFailedCertificateFileNotExists, Message = "Certificate file does not exist. File: '{0}'", Level = EventLevel.Warning)]

0 commit comments

Comments
 (0)