Skip to content

Commit 577337c

Browse files
author
Timothy Mothra
authored
[OTLP] include status code in failure log (#6154)
1 parent 7521728 commit 577337c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public override ExportClientResponse SendExportRequest(byte[] buffer, int conten
9393
grpcStatusDetailsHeader = GrpcProtocolHelpers.GetHeaderValue(trailingHeaders, GrpcStatusDetailsHeader);
9494
}
9595

96-
OpenTelemetryProtocolExporterEventSource.Log.ExportFailure(this.Endpoint.ToString(), "Export failed due to unexpected status code.");
96+
OpenTelemetryProtocolExporterEventSource.Log.ExportFailure(this.Endpoint, "Export failed due to unexpected status code.", status);
9797

9898
return new ExportClientGrpcResponse(
9999
success: false,

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Diagnostics.Tracing;
55
using Microsoft.Extensions.Configuration;
6+
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient.Grpc;
67
using OpenTelemetry.Internal;
78

89
namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
@@ -94,6 +95,15 @@ public void GrpcRetryDelayParsingFailed(string? grpcStatusDetailsHeader, Excepti
9495
}
9596
}
9697

98+
[NonEvent]
99+
public void ExportFailure(Uri endpoint, string message, Status status)
100+
{
101+
if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
102+
{
103+
this.ExportFailure(endpoint.ToString(), message, status.ToString());
104+
}
105+
}
106+
97107
[Event(2, Message = "Exporter failed send data to collector to {0} endpoint. Data will not be sent. Exception: {1}", Level = EventLevel.Error)]
98108
public void FailedToReachCollector(string rawCollectorUri, string ex)
99109
{
@@ -208,10 +218,10 @@ public void GrpcStatusWarning(string endpoint, string statusCode)
208218
this.WriteEvent(22, endpoint, statusCode);
209219
}
210220

211-
[Event(23, Message = "Export failed for {0}. Message: {1}", Level = EventLevel.Error)]
212-
public void ExportFailure(string endpoint, string message)
221+
[Event(23, Message = "Export failed for {0}. Message: {1}. {2}.", Level = EventLevel.Error)]
222+
public void ExportFailure(string endpoint, string message, string statusString)
213223
{
214-
this.WriteEvent(23, endpoint, message);
224+
this.WriteEvent(23, endpoint, message, statusString);
215225
}
216226

217227
[Event(24, Message = "Failed to parse gRPC retry delay from header grpcStatusDetailsHeader: '{0}'. Exception: {1}", Level = EventLevel.Warning)]

0 commit comments

Comments
 (0)