[OTLP] Dispose exporter if setup fails (#6398)
Co-authored-by: Rajkumar Rangaraj <rajrang@microsoft.com>
This commit is contained in:
parent
4dc60007ca
commit
570a6fa687
|
|
@ -327,6 +327,8 @@ public static class OtlpLogExporterHelperExtensions
|
|||
experimentalOptions!);
|
||||
#pragma warning restore CA2000 // Dispose objects before losing scope
|
||||
|
||||
try
|
||||
{
|
||||
if (configureExporterInstance != null)
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
|
|
@ -348,6 +350,12 @@ public static class OtlpLogExporterHelperExtensions
|
|||
batchOptions.MaxExportBatchSize);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
otlpExporter.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static T GetOptions<T>(
|
||||
IServiceProvider sp,
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@ public static class OtlpTraceExporterHelperExtensions
|
|||
BaseExporter<Activity> otlpExporter = new OtlpTraceExporter(exporterOptions!, sdkLimitOptions!, experimentalOptions!);
|
||||
#pragma warning restore CA2000 // Dispose objects before losing scope
|
||||
|
||||
try
|
||||
{
|
||||
if (configureExporterInstance != null)
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
|
|
@ -170,4 +172,10 @@ public static class OtlpTraceExporterHelperExtensions
|
|||
batchExportProcessorOptions.MaxExportBatchSize);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
otlpExporter.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue