Skip to content

Commit

Permalink
Deprecate exporterprofiles module in favor of xexporter (#11885)
Browse files Browse the repository at this point in the history
to allow adding more experimental data types.

Updates
#11778
  • Loading branch information
dmitryax authored Dec 13, 2024
1 parent 683e86a commit 0d94e09
Show file tree
Hide file tree
Showing 39 changed files with 476 additions and 190 deletions.
20 changes: 20 additions & 0 deletions .chloggen/deprecate-exporterprofiles.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: exporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate exporterprofiles module in favor of xexporter 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]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ consumer/xconsumer @open-telemetry/collector-approve
connector/connectorprofiles @open-telemetry/collector-approvers @mx-psi @dmathieu
exporter/exporterhelper/exporterhelperprofiles @open-telemetry/collector-approvers @mx-psi @dmathieu
exporter/exporterprofiles @open-telemetry/collector-approvers @mx-psi @dmathieu
exporter/xexporter @open-telemetry/collector-approvers @mx-psi @dmathieu
processor/processorprofiles @open-telemetry/collector-approvers @mx-psi @dmathieu
processor/xprocessor @open-telemetry/collector-approvers @mx-psi @dmathieu
receiver/receiverprofiles @open-telemetry/collector-approvers @mx-psi @dmathieu
Expand Down
2 changes: 1 addition & 1 deletion cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var replaceModules = []string{
"/connector/connectorprofiles",
"/exporter",
"/exporter/debugexporter",
"/exporter/exporterprofiles",
"/exporter/xexporter",
"/exporter/exportertest",
"/exporter/exporterhelper/exporterhelperprofiles",
"/exporter/nopexporter",
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ replaces:
- go.opentelemetry.io/collector/exporter => ../../exporter
- go.opentelemetry.io/collector/exporter/debugexporter => ../../exporter/debugexporter
- go.opentelemetry.io/collector/exporter/exportertest => ../../exporter/exportertest
- go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles
- go.opentelemetry.io/collector/exporter/xexporter => ../../exporter/xexporter
- go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles => ../../exporter/exporterhelper/exporterhelperprofiles
- go.opentelemetry.io/collector/exporter/nopexporter => ../../exporter/nopexporter
- go.opentelemetry.io/collector/exporter/otlpexporter => ../../exporter/otlpexporter
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ require (
go.opentelemetry.io/collector/consumer/consumertest v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.115.1-0.20241213185000-4593ba7de234 // indirect
go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles v0.115.0 // indirect
go.opentelemetry.io/collector/exporter/exporterprofiles v0.115.0 // indirect
go.opentelemetry.io/collector/exporter/exportertest v0.115.0 // indirect
go.opentelemetry.io/collector/exporter/xexporter v0.115.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.115.0 // indirect
go.opentelemetry.io/collector/extension/experimental/storage v0.115.0 // indirect
go.opentelemetry.io/collector/extension/extensioncapabilities v0.115.0 // indirect
Expand Down Expand Up @@ -225,7 +225,7 @@ replace go.opentelemetry.io/collector/exporter/debugexporter => ../../exporter/d

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

replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles
replace go.opentelemetry.io/collector/exporter/xexporter => ../../exporter/xexporter

replace go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles => ../../exporter/exporterhelper/exporterhelperprofiles

Expand Down
14 changes: 7 additions & 7 deletions exporter/debugexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"go.opentelemetry.io/collector/exporter/debugexporter/internal/otlptext"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles"
"go.opentelemetry.io/collector/exporter/exporterprofiles"
"go.opentelemetry.io/collector/exporter/xexporter"
)

// The value of "type" key in configuration.
Expand All @@ -31,13 +31,13 @@ const (

// NewFactory creates a factory for Debug exporter
func NewFactory() exporter.Factory {
return exporterprofiles.NewFactory(
return xexporter.NewFactory(
componentType,
createDefaultConfig,
exporterprofiles.WithTraces(createTraces, metadata.TracesStability),
exporterprofiles.WithMetrics(createMetrics, metadata.MetricsStability),
exporterprofiles.WithLogs(createLogs, metadata.LogsStability),
exporterprofiles.WithProfiles(createProfiles, metadata.ProfilesStability),
xexporter.WithTraces(createTraces, metadata.TracesStability),
xexporter.WithMetrics(createMetrics, metadata.MetricsStability),
xexporter.WithLogs(createLogs, metadata.LogsStability),
xexporter.WithProfiles(createProfiles, metadata.ProfilesStability),
)
}

Expand Down Expand Up @@ -86,7 +86,7 @@ func createLogs(ctx context.Context, set exporter.Settings, config component.Con
)
}

func createProfiles(ctx context.Context, set exporter.Settings, config component.Config) (exporterprofiles.Profiles, error) {
func createProfiles(ctx context.Context, set exporter.Settings, config component.Config) (xexporter.Profiles, error) {
cfg := config.(*Config)
exporterLogger := createLogger(cfg, set.TelemetrySettings.Logger)
debug := newDebugExporter(exporterLogger, cfg.Verbosity)
Expand Down
4 changes: 2 additions & 2 deletions exporter/debugexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/exporter/exporterprofiles"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/exporter/xexporter"
)

func TestCreateDefaultConfig(t *testing.T) {
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestCreateFactoryProfiles(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

te, err := factory.(exporterprofiles.Factory).CreateProfiles(context.Background(), exportertest.NewNopSettings(), cfg)
te, err := factory.(xexporter.Factory).CreateProfiles(context.Background(), exportertest.NewNopSettings(), cfg)
require.NoError(t, err)
assert.NotNil(t, te)
}
4 changes: 2 additions & 2 deletions exporter/debugexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require (
go.opentelemetry.io/collector/consumer v1.21.0
go.opentelemetry.io/collector/exporter v0.115.0
go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles v0.115.0
go.opentelemetry.io/collector/exporter/exporterprofiles v0.115.0
go.opentelemetry.io/collector/exporter/exportertest v0.115.0
go.opentelemetry.io/collector/exporter/xexporter v0.115.0
go.opentelemetry.io/collector/pdata v1.21.0
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/pdata/testdata v0.115.0
Expand Down Expand Up @@ -102,7 +102,7 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co

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

replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles
replace go.opentelemetry.io/collector/exporter/xexporter => ../xexporter

replace go.opentelemetry.io/collector/exporter/exporterhelper/exporterhelperprofiles => ../exporterhelper/exporterhelperprofiles

Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/exporterhelperprofiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ require (
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/exporter v0.115.0
go.opentelemetry.io/collector/exporter/exporterprofiles v0.115.0
go.opentelemetry.io/collector/exporter/exportertest v0.115.0
go.opentelemetry.io/collector/exporter/xexporter v0.115.0
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/pdata/testdata v0.115.0
go.opentelemetry.io/collector/pipeline/pipelineprofiles v0.115.0
Expand Down Expand Up @@ -85,7 +85,7 @@ replace go.opentelemetry.io/collector/extension => ../../../extension

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

replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporterprofiles
replace go.opentelemetry.io/collector/exporter/xexporter => ../../xexporter

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

Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/exporterhelperprofiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exporterprofiles"
"go.opentelemetry.io/collector/exporter/exporterqueue"
"go.opentelemetry.io/collector/exporter/xexporter"
"go.opentelemetry.io/collector/pdata/pprofile"
"go.opentelemetry.io/collector/pipeline/pipelineprofiles"
)
Expand Down Expand Up @@ -74,14 +74,14 @@ type profileExporter struct {
xconsumer.Profiles
}

// NewProfilesExporter creates an exporterprofiles.Profiles that records observability metrics and wraps every request with a Span.
// NewProfilesExporter creates an xexporter.Profiles that records observability metrics and wraps every request with a Span.
func NewProfilesExporter(
ctx context.Context,
set exporter.Settings,
cfg component.Config,
pusher xconsumer.ConsumeProfilesFunc,
options ...exporterhelper.Option,
) (exporterprofiles.Profiles, error) {
) (xexporter.Profiles, error) {
if cfg == nil {
return nil, errNilConfig
}
Expand Down Expand Up @@ -114,7 +114,7 @@ func NewProfilesRequestExporter(
set exporter.Settings,
converter RequestFromProfilesFunc,
options ...exporterhelper.Option,
) (exporterprofiles.Profiles, error) {
) (xexporter.Profiles, error) {
if set.Logger == nil {
return nil, errNilLogger
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/exporter/exporterprofiles"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/exporter/internal/queue"
"go.opentelemetry.io/collector/exporter/xexporter"
"go.opentelemetry.io/collector/pdata/pprofile"
"go.opentelemetry.io/collector/pdata/testdata"
)
Expand Down Expand Up @@ -290,7 +290,7 @@ func newPushProfilesData(retError error) xconsumer.ConsumeProfilesFunc {
}
}

func generateProfilesTraffic(t *testing.T, tracer trace.Tracer, le exporterprofiles.Profiles, numRequests int, wantError error) {
func generateProfilesTraffic(t *testing.T, tracer trace.Tracer, le xexporter.Profiles, numRequests int, wantError error) {
ld := testdata.GenerateProfiles(1)
ctx, span := tracer.Start(context.Background(), fakeProfilesParentSpanName)
defer span.End()
Expand All @@ -300,7 +300,7 @@ func generateProfilesTraffic(t *testing.T, tracer trace.Tracer, le exporterprofi
}

// nolint: unparam
func checkWrapSpanForProfilesExporter(t *testing.T, sr *tracetest.SpanRecorder, tracer trace.Tracer, le exporterprofiles.Profiles,
func checkWrapSpanForProfilesExporter(t *testing.T, sr *tracetest.SpanRecorder, tracer trace.Tracer, le xexporter.Profiles,
wantError error, numSampleRecords int64,
) {
const numRequests = 5
Expand Down
107 changes: 20 additions & 87 deletions exporter/exporterprofiles/exporter.go
Original file line number Diff line number Diff line change
@@ -1,109 +1,42 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Deprecated: [0.116.0] Use go.opentelemetry.io/collector/exporter/xexporter instead.
package exporterprofiles // import "go.opentelemetry.io/collector/exporter/exporterprofiles"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/pipeline"
)
import "go.opentelemetry.io/collector/exporter/xexporter"

// Profiles is an exporter that can consume profiles.
type Profiles interface {
component.Component
xconsumer.Profiles
}

type Factory interface {
exporter.Factory

// CreateProfiles creates a Profiles exporter based on this config.
// If the exporter type does not support tracing,
// this function returns the error [pipeline.ErrSignalNotSupported].
CreateProfiles(ctx context.Context, set exporter.Settings, cfg component.Config) (Profiles, error)
// Deprecated: [0.116.0] Use xeporter.Profiles instead.
type Profiles = xexporter.Profiles

// ProfilesStability gets the stability level of the Profiles exporter.
ProfilesStability() component.StabilityLevel
}
// Deprecated: [0.116.0] Use xeporter.Factory instead.
type Factory = xexporter.Factory

// FactoryOption apply changes to ReceiverOptions.
type FactoryOption interface {
// applyOption applies the option.
applyOption(o *factoryOpts)
}

// factoryOptionFunc is an ReceiverFactoryOption created through a function.
type factoryOptionFunc func(*factoryOpts)

func (f factoryOptionFunc) applyOption(o *factoryOpts) {
f(o)
}

type factoryOpts struct {
opts []exporter.FactoryOption
*factory
}
// Deprecated: [0.116.0] Use xeporter.FactoryOption instead.
type FactoryOption = xexporter.FactoryOption

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

// CreateProfiles implements Factory.CreateProfiles.
func (f CreateProfilesFunc) CreateProfiles(ctx context.Context, set exporter.Settings, cfg component.Config) (Profiles, error) {
if f == nil {
return nil, pipeline.ErrSignalNotSupported
}
return f(ctx, set, cfg)
}
// Deprecated: [0.116.0] Use xeporter.CreateProfilesFunc instead.
type CreateProfilesFunc = xexporter.CreateProfilesFunc

// WithTraces overrides the default "error not supported" implementation for CreateTraces and the default "undefined" stability level.
func WithTraces(createTraces exporter.CreateTracesFunc, sl component.StabilityLevel) FactoryOption {
return factoryOptionFunc(func(o *factoryOpts) {
o.opts = append(o.opts, exporter.WithTraces(createTraces, sl))
})
}
// Deprecated: [0.116.0] Use xeporter.WithTraces instead.
var WithTraces = xexporter.WithTraces

// WithMetrics overrides the default "error not supported" implementation for CreateMetrics and the default "undefined" stability level.
func WithMetrics(createMetrics exporter.CreateMetricsFunc, sl component.StabilityLevel) FactoryOption {
return factoryOptionFunc(func(o *factoryOpts) {
o.opts = append(o.opts, exporter.WithMetrics(createMetrics, sl))
})
}
// Deprecated: [0.116.0] Use xeporter.WithMetrics instead.
var WithMetrics = xexporter.WithMetrics

// WithLogs overrides the default "error not supported" implementation for CreateLogs and the default "undefined" stability level.
func WithLogs(createLogs exporter.CreateLogsFunc, sl component.StabilityLevel) FactoryOption {
return factoryOptionFunc(func(o *factoryOpts) {
o.opts = append(o.opts, exporter.WithLogs(createLogs, sl))
})
}
// Deprecated: [0.116.0] Use xeporter.WithLogs instead.
var WithLogs = xexporter.WithLogs

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

type factory struct {
exporter.Factory
CreateProfilesFunc
profilesStabilityLevel component.StabilityLevel
}

func (f *factory) ProfilesStability() component.StabilityLevel {
return f.profilesStabilityLevel
}
// Deprecated: [0.116.0] Use xeporter.WithProfiles instead.
var WithProfiles = xexporter.WithProfiles

// NewFactory returns a Factory.
func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory {
opts := factoryOpts{factory: &factory{}}
for _, opt := range options {
opt.applyOption(&opts)
}
opts.factory.Factory = exporter.NewFactory(cfgType, createDefaultConfig, opts.opts...)
return opts.factory
}
// Deprecated: [0.116.0] Use xeporter.NewFactory instead.
var NewFactory = xexporter.NewFactory
7 changes: 5 additions & 2 deletions exporter/exporterprofiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.115.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/exporter v0.115.0
go.opentelemetry.io/collector/pipeline v0.115.0
go.opentelemetry.io/collector/exporter/xexporter v0.115.0
)

require (
Expand All @@ -20,8 +19,10 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.115.0 // indirect
go.opentelemetry.io/collector/consumer v1.21.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/pprofile 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/trace v1.32.0 // indirect
Expand All @@ -38,6 +39,8 @@ require (

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

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

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

replace go.opentelemetry.io/collector/extension/experimental/storage => ../../extension/experimental/storage
Expand Down
Loading

0 comments on commit 0d94e09

Please sign in to comment.