Skip to content

Commit

Permalink
remove copy of sharedcomponent
Browse files Browse the repository at this point in the history
  • Loading branch information
mterhar committed Dec 11, 2024
1 parent 5fd4621 commit d16d6b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 181 deletions.
26 changes: 15 additions & 11 deletions receiver/libhoneyreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/libhoneyreceiver/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/libhoneyreceiver/internal/sharedcomponent"
)

const (
Expand Down Expand Up @@ -70,17 +70,20 @@ func createLogs(
nextConsumer consumer.Logs,
) (receiver.Logs, error) {
oCfg := cfg.(*Config)
r, err := receivers.LoadOrStore(
var err error
r := receivers.GetOrAdd(
oCfg,
func() (*libhoneyReceiver, error) {
return newLibhoneyReceiver(oCfg, &set)
func() (lh component.Component) {
lh, err = newLibhoneyReceiver(oCfg, &set)
return lh
},
)

if err != nil {
return nil, err
}

r.Unwrap().registerLogConsumer(nextConsumer)
r.Unwrap().(*libhoneyReceiver).registerLogConsumer(nextConsumer)
return r, nil
}

Expand All @@ -92,19 +95,20 @@ func createTraces(
nextConsumer consumer.Traces,
) (receiver.Traces, error) {
oCfg := cfg.(*Config)
r, err := receivers.LoadOrStore(
var err error
r := receivers.GetOrAdd(
oCfg,
func() (*libhoneyReceiver, error) {
return newLibhoneyReceiver(oCfg, &set)
func() (lh component.Component) {
lh, err = newLibhoneyReceiver(oCfg, &set)
return lh
},
)
if err != nil {
return nil, err
}

r.Unwrap().registerTraceConsumer(nextConsumer)
r.Unwrap().(*libhoneyReceiver).registerTraceConsumer(nextConsumer)
return r, nil
}

// Used the same pattern as the OTLP receiver. Requires sharedcomponent.go from core collector repo
var receivers = sharedcomponent.NewMap[*Config, *libhoneyReceiver]()
var receivers = sharedcomponent.NewSharedComponents()
1 change: 1 addition & 0 deletions receiver/libhoneyreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.115.0
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.11.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions receiver/libhoneyreceiver/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 0 additions & 170 deletions receiver/libhoneyreceiver/internal/sharedcomponent/sharedcomponent.go

This file was deleted.

0 comments on commit d16d6b5

Please sign in to comment.