From 71c22ac6a571ff579e031aba4ecaabe8a2b45226 Mon Sep 17 00:00:00 2001 From: Gabriel Lucaci Date: Wed, 23 Feb 2022 00:49:13 +0100 Subject: [PATCH] Otlp include batch transformation into try/catch scope (#2915) Co-authored-by: Cijo Thomas --- .../OtlpLogExporter.cs | 4 ++-- .../OtlpMetricExporter.cs | 4 ++-- .../OtlpTraceExporter.cs | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs index c033436b392..22fdd978d4d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs @@ -70,10 +70,10 @@ public override ExportResult Export(in Batch logRecordBatch) var request = new OtlpCollector.ExportLogsServiceRequest(); - request.AddBatch(this.ProcessResource, logRecordBatch); - try { + request.AddBatch(this.ProcessResource, logRecordBatch); + if (!this.exportClient.SendExportRequest(request)) { return ExportResult.Failure; diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs index 2cb2aae876d..7983c3da069 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs @@ -69,10 +69,10 @@ public override ExportResult Export(in Batch metrics) var request = new OtlpCollector.ExportMetricsServiceRequest(); - request.AddMetrics(this.ProcessResource, metrics); - try { + request.AddMetrics(this.ProcessResource, metrics); + if (!this.exportClient.SendExportRequest(request)) { return ExportResult.Failure; diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs index 1a846dd6575..71f19db313a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs @@ -69,10 +69,10 @@ public override ExportResult Export(in Batch activityBatch) var request = new OtlpCollector.ExportTraceServiceRequest(); - request.AddBatch(this.ProcessResource, activityBatch); - try { + request.AddBatch(this.ProcessResource, activityBatch); + if (!this.exportClient.SendExportRequest(request)) { return ExportResult.Failure; @@ -81,7 +81,6 @@ public override ExportResult Export(in Batch activityBatch) catch (Exception ex) { OpenTelemetryProtocolExporterEventSource.Log.ExportMethodException(ex); - return ExportResult.Failure; } finally