Skip to content

Commit

Permalink
[chore][testbed] Do not use export function carbonreceiver.New (#28858
Browse files Browse the repository at this point in the history
)

**Description:**
Do not use export function `carbonreceiver.New` and replace with
`factory.CreateMetricsReceiver`, then we can chore carbonreceiver to
make it pass checkapi tool.

**Link to tracking Issue:**

#28857
  • Loading branch information
sakulali authored Nov 2, 2023
1 parent 0e13821 commit 61c12ca
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions testbed/datareceivers/carbon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import (
"fmt"

"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/receivertest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/protocol"
"github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed"
)

Expand All @@ -35,18 +33,13 @@ func NewCarbonDataReceiver(port int) *CarbonDataReceiver {

// Start the receiver.
func (cr *CarbonDataReceiver) Start(_ consumer.Traces, mc consumer.Metrics, _ consumer.Logs) error {
addr := fmt.Sprintf("127.0.0.1:%d", cr.Port)
config := carbonreceiver.Config{
NetAddr: confignet.NetAddr{
Endpoint: addr,
},
Parser: &protocol.Config{
Type: "plaintext",
Config: &protocol.PlaintextConfig{},
},
}
factory := carbonreceiver.NewFactory()
cfg := factory.CreateDefaultConfig().(*carbonreceiver.Config)
cfg.Endpoint = fmt.Sprintf("127.0.0.1:%d", cr.Port)

set := receivertest.NewNopCreateSettings()
var err error
cr.receiver, err = carbonreceiver.New(receivertest.NewNopCreateSettings(), config, mc)
cr.receiver, err = factory.CreateMetricsReceiver(context.Background(), set, cfg, mc)
if err != nil {
return err
}
Expand Down

0 comments on commit 61c12ca

Please sign in to comment.