Skip to content

Commit

Permalink
use xpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Jan 7, 2025
1 parent 90176d7 commit e5920ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions collector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumerprofiles"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/receiverprofiles"
"go.opentelemetry.io/collector/receiver/xreceiver"

"go.opentelemetry.io/ebpf-profiler/collector/internal"
"go.opentelemetry.io/ebpf-profiler/internal/controller"
Expand All @@ -25,17 +25,17 @@ var (

// NewFactory creates a factory for the receiver.
func NewFactory() receiver.Factory {
return receiver.NewFactory(
return xreceiver.NewFactory(
typeStr,
defaultConfig,
receiverprofiles.WithProfiles(createProfilesReceiver, component.StabilityLevelAlpha))
xreceiver.WithProfiles(createProfilesReceiver, component.StabilityLevelAlpha))
}

func createProfilesReceiver(
_ context.Context,
_ receiver.Settings, //nolint:gocritic // we must respect the collector API
baseCfg component.Config,
nextConsumer consumerprofiles.Profiles) (receiverprofiles.Profiles, error) {
nextConsumer xconsumer.Profiles) (xreceiver.Profiles, error) {
cfg, ok := baseCfg.(*controller.Config)
if !ok {
return nil, errInvalidConfig
Expand Down
4 changes: 2 additions & 2 deletions collector/internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumerprofiles"
"go.opentelemetry.io/collector/consumer/xconsumer"

"go.opentelemetry.io/ebpf-profiler/internal/controller"
"go.opentelemetry.io/ebpf-profiler/reporter"
Expand All @@ -21,7 +21,7 @@ type Controller struct {
}

func NewController(cfg *controller.Config,
nextConsumer consumerprofiles.Profiles) (*Controller, error) {
nextConsumer xconsumer.Profiles) (*Controller, error) {
intervals := times.New(cfg.MonitorInterval,
cfg.ReporterInterval, cfg.ProbabilisticInterval)

Expand Down
6 changes: 3 additions & 3 deletions reporter/collector_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

lru "github.com/elastic/go-freelru"
log "github.com/sirupsen/logrus"
"go.opentelemetry.io/collector/consumer/consumerprofiles"
"go.opentelemetry.io/collector/consumer/xconsumer"

"go.opentelemetry.io/ebpf-profiler/libpf"
"go.opentelemetry.io/ebpf-profiler/libpf/xsync"
Expand All @@ -25,14 +25,14 @@ var _ Reporter = (*CollectorReporter)(nil)
type CollectorReporter struct {
*baseReporter

nextConsumer consumerprofiles.Profiles
nextConsumer xconsumer.Profiles

// runLoop handles the run loop
runLoop *runLoop
}

// NewCollector builds a new CollectorReporter
func NewCollector(cfg *Config, nextConsumer consumerprofiles.Profiles) (*CollectorReporter, error) {
func NewCollector(cfg *Config, nextConsumer xconsumer.Profiles) (*CollectorReporter, error) {
cgroupv2ID, err := lru.NewSynced[libpf.PID, string](cfg.CGroupCacheElements,
func(pid libpf.PID) uint32 { return uint32(pid) })
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions reporter/collector_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumerprofiles"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/pdata/pprofile"

"go.opentelemetry.io/ebpf-profiler/libpf"
Expand All @@ -17,7 +17,7 @@ func TestCollectorReporterReportTraceEvent(t *testing.T) {
name string
trace *libpf.Trace
meta *TraceEventMeta
nextFn consumerprofiles.ConsumeProfilesFunc
nextFn xconsumer.ConsumeProfilesFunc
}{
{
name: "with no next consumer",
Expand All @@ -42,11 +42,11 @@ func TestCollectorReporterReportTraceEvent(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {
var next consumerprofiles.Profiles
var next xconsumer.Profiles

if tt.nextFn != nil {
var err error
next, err = consumerprofiles.NewProfiles(tt.nextFn)
next, err = xconsumer.NewProfiles(tt.nextFn)
require.NoError(t, err)
}

Expand Down

0 comments on commit e5920ab

Please sign in to comment.