Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiles support in processor #10691

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/profiles-processor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Allow handling profiles in processor.

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

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# 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]
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ./config/configt

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

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

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

replace go.opentelemetry.io/collector/featuregate => ./featuregate
Expand All @@ -118,3 +116,5 @@ retract (
replace go.opentelemetry.io/collector/pdata/pprofile => ./pdata/pprofile

replace go.opentelemetry.io/collector/internal/globalgates => ./internal/globalgates

replace go.opentelemetry.io/collector/consumer/consumerprofiles => ./consumer/consumerprofiles
2 changes: 1 addition & 1 deletion processor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/collector/component v0.105.0
go.opentelemetry.io/collector/config/configtelemetry v0.105.0
go.opentelemetry.io/collector/consumer v0.105.0
go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0
go.opentelemetry.io/collector/consumer/consumertest v0.105.0
go.opentelemetry.io/collector/pdata v1.12.0
go.opentelemetry.io/collector/pdata/testdata v0.105.0
Expand Down Expand Up @@ -36,7 +37,6 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
Expand Down
38 changes: 38 additions & 0 deletions processor/internal/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

// Factory is a Factory interface for processors.
Expand Down Expand Up @@ -44,6 +45,14 @@
// LogsProcessorStability gets the stability level of the LogsProcessor.
LogsProcessorStability() component.StabilityLevel

// CreateProfilesProcessor creates a ProfilesProcessor based on this config.
// If the processor type does not support tracing or if the config is not valid,
// an error will be returned instead.
CreateProfilesProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumerprofiles.Profiles) (Profiles, error)

// ProfilesProcessorStability gets the stability level of the ProfilesProcessor.
ProfilesProcessorStability() component.StabilityLevel

unexportedFactoryFunc()
}

Expand Down Expand Up @@ -109,6 +118,21 @@
return f(ctx, set, cfg, nextConsumer)
}

// CreateProfilesFunc is the equivalent of Factory.CreateProfiles().
type CreateProfilesFunc func(context.Context, Settings, component.Config, consumerprofiles.Profiles) (Profiles, error)

// CreateProfilesProcessor implements Factory.CreateProfilesProcessor().
func (f CreateProfilesFunc) CreateProfilesProcessor(
ctx context.Context,
set Settings,
cfg component.Config,
nextConsumer consumerprofiles.Profiles) (Profiles, error) {
if f == nil {
return nil, component.ErrDataTypeIsNotSupported

Check warning on line 131 in processor/internal/factory.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/factory.go#L129-L131

Added lines #L129 - L131 were not covered by tests
}
return f(ctx, set, cfg, nextConsumer)

Check warning on line 133 in processor/internal/factory.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/factory.go#L133

Added line #L133 was not covered by tests
}

type factory struct {
cfgType component.Type
component.CreateDefaultConfigFunc
Expand All @@ -118,6 +142,8 @@
metricsStabilityLevel component.StabilityLevel
CreateLogsFunc
logsStabilityLevel component.StabilityLevel
CreateProfilesFunc
profilesStabilityLevel component.StabilityLevel
}

func (f *factory) Type() component.Type {
Expand All @@ -138,6 +164,10 @@
return f.logsStabilityLevel
}

func (f factory) ProfilesProcessorStability() component.StabilityLevel {
return f.profilesStabilityLevel

Check warning on line 168 in processor/internal/factory.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/factory.go#L167-L168

Added lines #L167 - L168 were not covered by tests
}

// WithTraces overrides the default "error not supported" implementation for CreateTraces and the default "undefined" stability level.
func WithTraces(createTraces CreateTracesFunc, sl component.StabilityLevel) FactoryOption {
return factoryOptionFunc(func(o *factory) {
Expand All @@ -162,6 +192,14 @@
})
}

// WithProfiles overrides the default "error not supported" implementation for CreateProfiles and the default "undefined" stability level.
func WithProfiles(createProfiles CreateProfilesFunc, sl component.StabilityLevel) FactoryOption {
return factoryOptionFunc(func(o *factory) {
o.profilesStabilityLevel = sl
o.CreateProfilesFunc = createProfiles
})

Check warning on line 200 in processor/internal/factory.go

View check run for this annotation

Codecov / codecov/patch

processor/internal/factory.go#L196-L200

Added lines #L196 - L200 were not covered by tests
}

// NewFactory returns a Factory.
func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory {
f := &factory{
Expand Down
15 changes: 15 additions & 0 deletions processor/internal/profiles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package internal // import "go.opentelemetry.io/collector/processor/internal"

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumerprofiles"
)

// Profiles is a processor that can consume profiles.
type Profiles interface {
component.Component
consumerprofiles.Profiles
}
1 change: 1 addition & 0 deletions processor/processorprofiles/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
62 changes: 62 additions & 0 deletions processor/processorprofiles/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module go.opentelemetry.io/collector/processor/processorprofiles

go 1.21.0

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.105.0
go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0
go.opentelemetry.io/collector/consumer/consumertest v0.105.0
go.opentelemetry.io/collector/processor v0.105.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // 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/config/configtelemetry v0.105.0 // indirect
go.opentelemetry.io/collector/consumer v0.105.0 // indirect
go.opentelemetry.io/collector/pdata v1.12.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

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

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

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

replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates

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

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

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

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

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

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

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

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

replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest
111 changes: 111 additions & 0 deletions processor/processorprofiles/go.sum

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

21 changes: 21 additions & 0 deletions processor/processorprofiles/processor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package processorprofiles // import "go.opentelemetry.io/collector/processor/processorprofiles"

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/internal"
)

// Profiles is a processor that can consume profiles.
type Profiles = internal.Profiles

// CreateProfilesFunc is the equivalent of Factory.CreateProfiles().
type CreateProfilesFunc = internal.CreateProfilesFunc

// WithProfiles overrides the default "error not supported" implementation for CreateProfiles and the default "undefined" stability level.
func WithProfiles(createProfiles CreateProfilesFunc, sl component.StabilityLevel) processor.FactoryOption {
return internal.WithProfiles(createProfiles, sl)
}
Loading
Loading