Skip to content

Commit 46d0335

Browse files
committed
Add a case for respData.Len() == 0
1 parent af08f24 commit 46d0335

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

exporters/otlp/otlpmetric/otlpmetrichttp/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func (c *client) UploadMetrics(ctx context.Context, protoMetrics *metricpb.Resou
166166
if _, err := io.Copy(&respData, resp.Body); err != nil {
167167
return err
168168
}
169+
if respData.Len() == 0 {
170+
return nil
171+
}
172+
169173
if resp.Header.Get("Content-Type") == "application/x-protobuf" {
170174
var respProto colmetricpb.ExportMetricsServiceResponse
171175
if err := proto.Unmarshal(respData.Bytes(), &respProto); err != nil {

exporters/otlp/otlptrace/otlptracehttp/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
177177
if _, err := io.Copy(&respData, resp.Body); err != nil {
178178
return err
179179
}
180+
if respData.Len() == 0 {
181+
return nil
182+
}
180183

181184
if resp.Header.Get("Content-Type") == "application/x-protobuf" {
182185
var respProto coltracepb.ExportTraceServiceResponse

0 commit comments

Comments
 (0)