Skip to content

Commit

Permalink
sapmreceiver: allow multiple Start() calls (#11518)
Browse files Browse the repository at this point in the history
Description:
Fixing a bug - With open-telemetry/opentelemetry-collector@b05c0f3 using the splunk_hec receiver in multiple pipelines causes a port conflict by trying to recreate an existing server. These changes ensure subsequent Start() calls are noops.

Testing: Updated existing test with repeated Start invocation.

Documentation: Changelog update
  • Loading branch information
emaderer committed Jun 24, 2022
1 parent 4673db9 commit 1c70a76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
- `signalfxreceiver`: Fix issue where component instance use in multiple pipelines leads to start failures (#11513)
- `splunkhecreceiver`: Fix issue where component instance use in multiple pipelines leads to start failures (#11517)

### 🧰 Bug fixes 🧰

- `sapmreceiver`: Fix issue where component instance use in multiple pipelines leads to start failures (#11518)

## v0.54.0

## 🛑 Breaking changes 🛑
Expand Down
4 changes: 4 additions & 0 deletions receiver/sapmreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (sr *sapmReceiver) HTTPHandlerFunc(rw http.ResponseWriter, req *http.Reques

// Start starts the sapmReceiver's server.
func (sr *sapmReceiver) Start(_ context.Context, host component.Host) error {
// server.Handler will be nil on initial call, otherwise noop.
if sr.server != nil && sr.server.Handler != nil {
return nil
}
// set up the listener
ln, err := sr.config.HTTPServerSettings.ToListener()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions receiver/sapmreceiver/trace_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func setupReceiver(t *testing.T, config *Config, sink *consumertest.TracesSink)

mh := newAssertNoErrorHost(t)
require.NoError(t, sr.Start(context.Background(), mh), "should not have failed to start trace reception")
require.NoError(t, sr.Start(context.Background(), mh), "should not fail to start log on second Start call")

// If there are errors reported through host.ReportFatalError() this will retrieve it.
<-time.After(500 * time.Millisecond)
Expand Down

0 comments on commit 1c70a76

Please sign in to comment.