Skip to content

Commit

Permalink
Deprecate processorhelperprofiles module in favor of xprocessorhelper (
Browse files Browse the repository at this point in the history
…#11889)

to allow adding more experimental data types

Updates
#11778
  • Loading branch information
dmitryax authored Dec 14, 2024
1 parent 97f6c3a commit 7941703
Show file tree
Hide file tree
Showing 11 changed files with 443 additions and 99 deletions.
20 changes: 20 additions & 0 deletions .chloggen/deprecate-processorhelperprofiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: processorhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate processorhelperprofiles module in favor of xprocessorhelper to allow adding more experimental data types.

# One or more tracking issues or pull requests related to the change
issues: [11778]

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
7 changes: 5 additions & 2 deletions processor/processorhelper/processorhelperprofiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ require (
go.opentelemetry.io/collector/component/componenttest v0.115.0
go.opentelemetry.io/collector/consumer v1.21.0
go.opentelemetry.io/collector/consumer/consumertest v0.115.0
go.opentelemetry.io/collector/consumer/xconsumer v0.115.1-0.20241213185000-4593ba7de234
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/processor v0.115.0
go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper v0.0.0-00010101000000-000000000000
go.opentelemetry.io/collector/processor/processortest v0.115.0
go.opentelemetry.io/collector/processor/xprocessor v0.115.0
)

require (
Expand All @@ -27,9 +26,11 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/component/componentstatus v0.115.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.115.1-0.20241213185000-4593ba7de234 // indirect
go.opentelemetry.io/collector/pdata v1.21.0 // indirect
go.opentelemetry.io/collector/pdata/testdata v0.115.0 // indirect
go.opentelemetry.io/collector/pipeline v0.115.0 // indirect
go.opentelemetry.io/collector/processor/xprocessor v0.115.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
Expand Down Expand Up @@ -73,3 +74,5 @@ replace go.opentelemetry.io/collector/component/componentstatus => ../../../comp
replace go.opentelemetry.io/collector/processor/processortest => ../../processortest

replace go.opentelemetry.io/collector/processor/xprocessor => ../../xprocessor

replace go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper => ../xprocessorhelper
58 changes: 10 additions & 48 deletions processor/processorhelper/processorhelperprofiles/processor.go
Original file line number Diff line number Diff line change
@@ -1,64 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Deprecated: [0.116.0] Use go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper instead.
package processorhelperprofiles // import "go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles"

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
)
import "go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper"

// Option apply changes to internalOptions.
type Option interface {
apply(*baseSettings)
}

type optionFunc func(*baseSettings)

func (of optionFunc) apply(e *baseSettings) {
of(e)
}
// Deprecated: [0.116.0] Use xprocessorhelper.Option instead.
type Option = xprocessorhelper.Option

// WithStart overrides the default Start function for an processor.
// The default shutdown function does nothing and always returns nil.
func WithStart(start component.StartFunc) Option {
return optionFunc(func(o *baseSettings) {
o.StartFunc = start
})
}
// Deprecated: [0.116.0] Use xprocessorhelper.WithStart instead.
var WithStart = xprocessorhelper.WithStart

// WithShutdown overrides the default Shutdown function for an processor.
// The default shutdown function does nothing and always returns nil.
func WithShutdown(shutdown component.ShutdownFunc) Option {
return optionFunc(func(o *baseSettings) {
o.ShutdownFunc = shutdown
})
}
// Deprecated: [0.116.0] Use xprocessorhelper.WithShutdown instead.
var WithShutdown = xprocessorhelper.WithShutdown

// WithCapabilities overrides the default GetCapabilities function for an processor.
// The default GetCapabilities function returns mutable capabilities.
func WithCapabilities(capabilities consumer.Capabilities) Option {
return optionFunc(func(o *baseSettings) {
o.consumerOptions = append(o.consumerOptions, consumer.WithCapabilities(capabilities))
})
}

type baseSettings struct {
component.StartFunc
component.ShutdownFunc
consumerOptions []consumer.Option
}

// fromOptions returns the internal settings starting from the default and applying all options.
func fromOptions(options []Option) *baseSettings {
// Start from the default options:
opts := &baseSettings{
consumerOptions: []consumer.Option{consumer.WithCapabilities(consumer.Capabilities{MutatesData: true})},
}

for _, op := range options {
op.apply(opts)
}

return opts
}
// Deprecated: [0.116.0] Use xprocessorhelper.WithCapabilities instead.
var WithCapabilities = xprocessorhelper.WithCapabilities
55 changes: 6 additions & 49 deletions processor/processorhelper/processorhelperprofiles/profiles.go
Original file line number Diff line number Diff line change
@@ -1,61 +1,18 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Deprecated: [0.116.0] Use go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper instead.
package processorhelperprofiles // import "go.opentelemetry.io/collector/processor/processorhelper/processorhelperprofiles"

import (
"context"
"errors"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/pdata/pprofile"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processorhelper"
"go.opentelemetry.io/collector/processor/xprocessor"
"go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper"
)

// ProcessProfilesFunc is a helper function that processes the incoming data and returns the data to be sent to the next component.
// If error is returned then returned data are ignored. It MUST not call the next component.
type ProcessProfilesFunc func(context.Context, pprofile.Profiles) (pprofile.Profiles, error)

type profiles struct {
component.StartFunc
component.ShutdownFunc
xconsumer.Profiles
}
// Deprecated: [0.116.0] Use xprocessorhelper.ProcessProfilesFunc instead.
type ProcessProfilesFunc = xprocessorhelper.ProcessProfilesFunc

// NewProfiles creates a xprocessor.Profiles that ensure context propagation.
func NewProfiles(
_ context.Context,
_ processor.Settings,
_ component.Config,
nextConsumer xconsumer.Profiles,
profilesFunc ProcessProfilesFunc,
options ...Option,
) (xprocessor.Profiles, error) {
if profilesFunc == nil {
return nil, errors.New("nil profilesFunc")
}

bs := fromOptions(options)
profilesConsumer, err := xconsumer.NewProfiles(func(ctx context.Context, pd pprofile.Profiles) (err error) {
pd, err = profilesFunc(ctx, pd)
if err != nil {
if errors.Is(err, processorhelper.ErrSkipProcessingData) {
return nil
}
return err
}
return nextConsumer.ConsumeProfiles(ctx, pd)
}, bs.consumerOptions...)
if err != nil {
return nil, err
}

return &profiles{
StartFunc: bs.StartFunc,
ShutdownFunc: bs.ShutdownFunc,
Profiles: profilesConsumer,
}, nil
}
// Deprecated: [0.116.0] Use xprocessorhelper.NewProfiles instead.
var NewProfiles = xprocessorhelper.NewProfiles
1 change: 1 addition & 0 deletions processor/processorhelper/xprocessorhelper/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../../Makefile.Common
75 changes: 75 additions & 0 deletions processor/processorhelper/xprocessorhelper/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper

go 1.22.0

require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.115.0
go.opentelemetry.io/collector/component/componenttest v0.115.0
go.opentelemetry.io/collector/consumer v1.21.0
go.opentelemetry.io/collector/consumer/consumertest v0.115.0
go.opentelemetry.io/collector/consumer/xconsumer v0.115.1-0.20241213185000-4593ba7de234
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/processor v0.115.0
go.opentelemetry.io/collector/processor/processortest v0.115.0
go.opentelemetry.io/collector/processor/xprocessor v0.115.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/component/componentstatus v0.115.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.115.0 // indirect
go.opentelemetry.io/collector/pdata v1.21.0 // indirect
go.opentelemetry.io/collector/pdata/testdata v0.115.0 // indirect
go.opentelemetry.io/collector/pipeline v0.115.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.68.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace go.opentelemetry.io/collector/consumer/consumertest => ../../../consumer/consumertest

replace go.opentelemetry.io/collector/pdata/pprofile => ../../../pdata/pprofile

replace go.opentelemetry.io/collector/pdata/testdata => ../../../pdata/testdata

replace go.opentelemetry.io/collector/processor => ../../../processor

replace go.opentelemetry.io/collector/consumer => ../../../consumer

replace go.opentelemetry.io/collector/consumer/xconsumer => ../../../consumer/xconsumer

replace go.opentelemetry.io/collector/component => ../../../component

replace go.opentelemetry.io/collector/component/componenttest => ../../../component/componenttest

replace go.opentelemetry.io/collector/pdata => ../../../pdata

replace go.opentelemetry.io/collector/config/configtelemetry => ../../../config/configtelemetry

replace go.opentelemetry.io/collector/pipeline => ../../../pipeline

replace go.opentelemetry.io/collector/component/componentstatus => ../../../component/componentstatus

replace go.opentelemetry.io/collector/processor/processortest => ../../processortest

replace go.opentelemetry.io/collector/processor/xprocessor => ../../xprocessor
98 changes: 98 additions & 0 deletions processor/processorhelper/xprocessorhelper/go.sum

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

Loading

0 comments on commit 7941703

Please sign in to comment.