Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 4401eb7

Browse files
committed
receiver/opencensus/ocmetrics: ignore io.EOF on JSON upload
When the grpc-gateway was added to this receiver/opencensus Trace receiver in PR #270, we recognized that browsers and other sources that send JSON in one burst won't stream so would encounter an io.EOF. This PR makes the metrics receiver replicates that behavior. We'll get it this PR also ported over to the OpenTelemtry service. Fixes #610
1 parent d4f12f7 commit 4401eb7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

receiver/opencensusreceiver/ocmetrics/opencensus.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package ocmetrics
1717
import (
1818
"context"
1919
"errors"
20+
"io"
2021
"time"
2122

2223
"google.golang.org/api/support/bundler"
@@ -110,6 +111,11 @@ func (ocr *Receiver) Export(mes agentmetricspb.MetricsService_ExportServer) erro
110111

111112
recv, err = mes.Recv()
112113
if err != nil {
114+
if err == io.EOF {
115+
// Do not return EOF as an error so that grpc-gateway calls get an empty
116+
// response with HTTP status code 200 rather than a 500 error with EOF.
117+
return nil
118+
}
113119
return err
114120
}
115121
}

0 commit comments

Comments
 (0)