Skip to content

Commit

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

**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:**

open-telemetry#28857
  • Loading branch information
sakulali authored and RoryCrispin committed Nov 24, 2023
1 parent 7ad6f29 commit b28c7f2
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 b28c7f2

Please sign in to comment.