Skip to content

Commit

Permalink
[receiver/signalfx]fix lint for signalfxreceiver (#12592)
Browse files Browse the repository at this point in the history
* [receiver/signalfx]fix lint for fix-link-for-signalfxreceiver

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* Update receiver/signalfxreceiver/receiver_test.go

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>

* fix for reviews

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
  • Loading branch information
fatsheep9146 and dmitryax authored Jul 20, 2022
1 parent 697bf7a commit f3b82a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions receiver/signalfxreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// nolint:errcheck
package signalfxreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver"

import (
Expand Down Expand Up @@ -215,7 +214,10 @@ func (r *sfxReceiver) writeResponse(ctx context.Context, resp http.ResponseWrite
}

resp.WriteHeader(http.StatusOK)
resp.Write(okRespBody)
_, err = resp.Write(okRespBody)
if err != nil {
r.failRequest(ctx, resp, http.StatusInternalServerError, errNextConsumerRespBody, err)
}
}

func (r *sfxReceiver) handleDatapointReq(resp http.ResponseWriter, req *http.Request) {
Expand All @@ -239,7 +241,7 @@ func (r *sfxReceiver) handleDatapointReq(resp http.ResponseWriter, req *http.Req

if len(msg.Datapoints) == 0 {
r.obsrecv.EndMetricsOp(ctx, typeStr, 0, nil)
resp.Write(okRespBody)
_, _ = resp.Write(okRespBody)
return
}

Expand Down Expand Up @@ -285,7 +287,7 @@ func (r *sfxReceiver) handleEventReq(resp http.ResponseWriter, req *http.Request

if len(msg.Events) == 0 {
r.obsrecv.EndMetricsOp(ctx, typeStr, 0, nil)
resp.Write(okRespBody)
_, _ = resp.Write(okRespBody)
return
}

Expand Down
13 changes: 9 additions & 4 deletions receiver/signalfxreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// nolint:errcheck
package signalfxreceiver

import (
Expand Down Expand Up @@ -109,7 +108,9 @@ func Test_signalfxeceiver_EndToEnd(t *testing.T) {
require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost()))
require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost()))
runtime.Gosched()
defer r.Shutdown(context.Background())
defer func() {
require.NoError(t, r.Shutdown(context.Background()))
}()

unixSecs := int64(1574092046)
unixNSecs := int64(11 * time.Millisecond)
Expand Down Expand Up @@ -178,7 +179,9 @@ func Test_signalfxeceiver_EndToEnd(t *testing.T) {
}
return false
}, 10*time.Second, 5*time.Millisecond, "failed to wait for the port to be open")
defer exp.Shutdown(context.Background())
defer func() {
require.NoError(t, exp.Shutdown(context.Background()))
}()
require.NoError(t, exp.ConsumeMetrics(context.Background(), want))

mds := sink.AllMetrics()
Expand Down Expand Up @@ -551,7 +554,9 @@ func Test_sfxReceiver_TLS(t *testing.T) {
sink := new(consumertest.MetricsSink)
r := newReceiver(componenttest.NewNopReceiverCreateSettings(), *cfg)
r.RegisterMetricsConsumer(sink)
defer r.Shutdown(context.Background())
defer func() {
require.NoError(t, r.Shutdown(context.Background()))
}()

mh := newAssertNoErrorHost(t)
require.NoError(t, r.Start(context.Background(), mh), "should not have failed to start metric reception")
Expand Down

0 comments on commit f3b82a4

Please sign in to comment.