Catch general exception in OltpExporter (#1634)

* Catch general exception in OltpExporter

* Corrected typo
This commit is contained in:
Utkarsh Umesan Pillai 2020-11-30 13:19:10 -08:00 committed by GitHub
parent fcc0b56904
commit 1630fb3abb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -43,6 +43,15 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation
}
}
[NonEvent]
public void ExportMethodException(Exception ex)
{
if (Log.IsEnabled(EventLevel.Error, (EventKeywords)(-1)))
{
this.ExportMethodException(ex.ToInvariantString());
}
}
[Event(1, Message = "Exporter failed to convert SpanData content into gRPC proto definition. Data will not be sent. Exception: {0}", Level = EventLevel.Error)]
public void FailedToConvertToProtoDefinitionError(string ex)
{
@ -60,5 +69,11 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation
{
this.WriteEvent(3, className, methodName);
}
[Event(4, Message = "Unknown error in export method: {0}", Level = EventLevel.Error)]
public void ExportMethodException(string ex)
{
this.WriteEvent(4, ex);
}
}
}

View File

@ -85,6 +85,12 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol
return ExportResult.Failure;
}
catch (Exception ex)
{
OpenTelemetryProtocolExporterEventSource.Log.ExportMethodException(ex);
return ExportResult.Failure;
}
finally
{
request.Return();