[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,25 +327,33 @@ public static class OtlpLogExporterHelperExtensions
|
|||
experimentalOptions!);
|
||||
#pragma warning restore CA2000 // Dispose objects before losing scope
|
||||
|
||||
if (configureExporterInstance != null)
|
||||
try
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
}
|
||||
if (configureExporterInstance != null)
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
}
|
||||
|
||||
if (processorOptions!.ExportProcessorType == ExportProcessorType.Simple)
|
||||
{
|
||||
return new SimpleLogRecordExportProcessor(otlpExporter);
|
||||
}
|
||||
else
|
||||
{
|
||||
var batchOptions = processorOptions.BatchExportProcessorOptions;
|
||||
if (processorOptions!.ExportProcessorType == ExportProcessorType.Simple)
|
||||
{
|
||||
return new SimpleLogRecordExportProcessor(otlpExporter);
|
||||
}
|
||||
else
|
||||
{
|
||||
var batchOptions = processorOptions.BatchExportProcessorOptions;
|
||||
|
||||
return new BatchLogRecordExportProcessor(
|
||||
otlpExporter,
|
||||
batchOptions.MaxQueueSize,
|
||||
batchOptions.ScheduledDelayMilliseconds,
|
||||
batchOptions.ExporterTimeoutMilliseconds,
|
||||
batchOptions.MaxExportBatchSize);
|
||||
return new BatchLogRecordExportProcessor(
|
||||
otlpExporter,
|
||||
batchOptions.MaxQueueSize,
|
||||
batchOptions.ScheduledDelayMilliseconds,
|
||||
batchOptions.ExporterTimeoutMilliseconds,
|
||||
batchOptions.MaxExportBatchSize);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
otlpExporter.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,23 +151,31 @@ public static class OtlpTraceExporterHelperExtensions
|
|||
BaseExporter<Activity> otlpExporter = new OtlpTraceExporter(exporterOptions!, sdkLimitOptions!, experimentalOptions!);
|
||||
#pragma warning restore CA2000 // Dispose objects before losing scope
|
||||
|
||||
if (configureExporterInstance != null)
|
||||
try
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
}
|
||||
if (configureExporterInstance != null)
|
||||
{
|
||||
otlpExporter = configureExporterInstance(otlpExporter);
|
||||
}
|
||||
|
||||
if (exportProcessorType == ExportProcessorType.Simple)
|
||||
{
|
||||
return new SimpleActivityExportProcessor(otlpExporter);
|
||||
if (exportProcessorType == ExportProcessorType.Simple)
|
||||
{
|
||||
return new SimpleActivityExportProcessor(otlpExporter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BatchActivityExportProcessor(
|
||||
otlpExporter,
|
||||
batchExportProcessorOptions!.MaxQueueSize,
|
||||
batchExportProcessorOptions.ScheduledDelayMilliseconds,
|
||||
batchExportProcessorOptions.ExporterTimeoutMilliseconds,
|
||||
batchExportProcessorOptions.MaxExportBatchSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch
|
||||
{
|
||||
return new BatchActivityExportProcessor(
|
||||
otlpExporter,
|
||||
batchExportProcessorOptions!.MaxQueueSize,
|
||||
batchExportProcessorOptions.ScheduledDelayMilliseconds,
|
||||
batchExportProcessorOptions.ExporterTimeoutMilliseconds,
|
||||
batchExportProcessorOptions.MaxExportBatchSize);
|
||||
otlpExporter.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue