Skip to content

Commit 3bec577

Browse files
atoulmecodebotensongy23
authored
[chore] start and stop otlp exporter once (#32809)
The testbed starts and stops the exporter once per signal, but we know it's the same exporter underneath. This PR changes the behavior of testbed to start and stop the exporter just once. This change is needed to support open-telemetry/opentelemetry-collector#10059 --------- Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Yang Song <[email protected]>
1 parent c160941 commit 3bec577

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

testbed/testbed/receivers.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ func (bor *BaseOTLPDataReceiver) Start(tc consumer.Traces, mc consumer.Metrics,
7979
return err
8080
}
8181

82-
if err = bor.traceReceiver.Start(context.Background(), componenttest.NewNopHost()); err != nil {
83-
return err
84-
}
85-
if err = bor.metricsReceiver.Start(context.Background(), componenttest.NewNopHost()); err != nil {
86-
return err
87-
}
82+
// we reuse the receiver across signals. Starting the log receiver starts the metrics and traces receiver.
8883
return bor.logReceiver.Start(context.Background(), componenttest.NewNopHost())
8984
}
9085

@@ -104,12 +99,7 @@ func (bor *BaseOTLPDataReceiver) WithQueue(sendingQueue string) *BaseOTLPDataRec
10499
}
105100

106101
func (bor *BaseOTLPDataReceiver) Stop() error {
107-
if err := bor.traceReceiver.Shutdown(context.Background()); err != nil {
108-
return err
109-
}
110-
if err := bor.metricsReceiver.Shutdown(context.Background()); err != nil {
111-
return err
112-
}
102+
// we reuse the receiver across signals. Shutting down the log receiver shuts down the metrics and traces receiver.
113103
return bor.logReceiver.Shutdown(context.Background())
114104
}
115105

0 commit comments

Comments
 (0)