Skip to content

Commit 6a70665

Browse files
[OTLP] Avoid redundant allocations and log HTTP export success (#6562)
1 parent 72e6084 commit 6a70665

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpGrpcExportClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public override ExportClientResponse SendExportRequest(byte[] buffer, int conten
6767
status = new Status(StatusCode.Internal, "Failed to deserialize response message.");
6868
}
6969

70-
OpenTelemetryProtocolExporterEventSource.Log.ResponseDeserializationFailed(this.Endpoint.ToString());
70+
OpenTelemetryProtocolExporterEventSource.Log.ResponseDeserializationFailed(this.Endpoint);
7171

7272
return new ExportClientGrpcResponse(
7373
success: false,
@@ -88,7 +88,7 @@ public override ExportClientResponse SendExportRequest(byte[] buffer, int conten
8888

8989
if (status.StatusCode == StatusCode.OK)
9090
{
91-
OpenTelemetryProtocolExporterEventSource.Log.ExportSuccess(this.Endpoint.ToString(), "Export completed successfully.");
91+
OpenTelemetryProtocolExporterEventSource.Log.ExportSuccess(this.Endpoint, "Export completed successfully.");
9292
return SuccessExportResponse;
9393
}
9494

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpHttpExportClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public override ExportClientResponse SendExportRequest(byte[] buffer, int conten
3939
return new ExportClientHttpResponse(success: false, deadlineUtc: deadlineUtc, response: httpResponse, ex);
4040
}
4141

42+
OpenTelemetryProtocolExporterEventSource.Log.ExportSuccess(this.Endpoint, "Export completed successfully.");
4243
return SuccessExportResponse;
4344
}
4445
catch (HttpRequestException ex)

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ public void ExportFailure(Uri endpoint, string message, Status status)
104104
}
105105
}
106106

107+
[NonEvent]
108+
public void ExportSuccess(Uri endpoint, string message)
109+
{
110+
if (Log.IsEnabled(EventLevel.Informational, EventKeywords.All))
111+
{
112+
this.ExportSuccess(endpoint.ToString(), message);
113+
}
114+
}
115+
116+
[NonEvent]
117+
public void ResponseDeserializationFailed(Uri endpoint)
118+
{
119+
if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
120+
{
121+
this.ResponseDeserializationFailed(endpoint.ToString());
122+
}
123+
}
124+
107125
[Event(2, Message = "Exporter failed send data to collector to {0} endpoint. Data will not be sent. Exception: {1}", Level = EventLevel.Error)]
108126
public void FailedToReachCollector(string rawCollectorUri, string ex)
109127
{

0 commit comments

Comments
 (0)