Skip to content

Commit

Permalink
Deprecate consumererrorprofiles module in favor of xconsumererror (#1…
Browse files Browse the repository at this point in the history
…1892)

to allow adding more experimental data types.

Updates
#11778
  • Loading branch information
dmitryax authored Dec 14, 2024
1 parent 9206c68 commit c6c249d
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 35 deletions.
20 changes: 20 additions & 0 deletions .chloggen/deprecate-consumererrorprofiles.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: consumererror

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate consumererrorprofiles module in favor of xconsumererror 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]
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 @@ -61,7 +61,7 @@ var replaceModules = []string{
"/confmap/provider/yamlprovider",
"/consumer",
"/consumer/consumererror",
"/consumer/consumererror/consumererrorprofiles",
"/consumer/consumererror/xconsumererror",
"/consumer/xconsumer",
"/consumer/consumertest",
"/connector",
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 @@ -61,7 +61,7 @@ replaces:
- go.opentelemetry.io/collector/consumer => ../../consumer
- go.opentelemetry.io/collector/consumer/xconsumer => ../../consumer/xconsumer
- go.opentelemetry.io/collector/consumer/consumererror => ../../consumer/consumererror
- go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../consumer/consumererror/consumererrorprofiles
- go.opentelemetry.io/collector/consumer/consumererror/xconsumererror => ../../consumer/consumererror/xconsumererror
- go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest
- go.opentelemetry.io/collector/connector => ../../connector
- go.opentelemetry.io/collector/connector/connectortest => ../../connector/connectortest
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ require (
go.opentelemetry.io/collector/connector/connectortest v0.115.0 // indirect
go.opentelemetry.io/collector/consumer v1.21.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.115.0 // indirect
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
Expand Down Expand Up @@ -207,7 +207,7 @@ replace go.opentelemetry.io/collector/consumer/xconsumer => ../../consumer/xcons

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

replace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../consumer/consumererror/consumererrorprofiles
replace go.opentelemetry.io/collector/consumer/consumererror/xconsumererror => ../../consumer/consumererror/xconsumererror

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

Expand Down
7 changes: 5 additions & 2 deletions consumer/consumererror/consumererrorprofiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ go 1.22.0

require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/consumer/consumererror v0.115.0
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.0.0-00010101000000-000000000000
go.opentelemetry.io/collector/pdata/testdata v0.115.0
)

Expand All @@ -16,7 +15,9 @@ require (
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/consumer/consumererror v0.115.0 // indirect
go.opentelemetry.io/collector/pdata v1.21.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.115.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
Expand All @@ -34,3 +35,5 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../../../pdata/testdata
replace go.opentelemetry.io/collector/pdata/pprofile => ../../../pdata/pprofile

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

replace go.opentelemetry.io/collector/consumer/consumererror/xconsumererror => ../xconsumererror
20 changes: 5 additions & 15 deletions consumer/consumererror/consumererrorprofiles/signalerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@

package consumererrorprofiles // import "go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles"

import (
"go.opentelemetry.io/collector/consumer/consumererror/internal"
"go.opentelemetry.io/collector/pdata/pprofile"
)
import "go.opentelemetry.io/collector/consumer/consumererror/xconsumererror"

// Profiles is an error that may carry associated Profile data for a subset of received data
// that failed to be processed or sent.
type Profiles struct {
internal.Retryable[pprofile.Profiles]
}
// Deprecated: [0.116.0] Use xconsumererror.Profiles instead.
type Profiles = xconsumererror.Profiles

// NewProfiles creates a Profiles that can encapsulate received data that failed to be processed or sent.
func NewProfiles(err error, data pprofile.Profiles) error {
return Profiles{
Retryable: internal.Retryable[pprofile.Profiles]{
Err: err,
Value: data,
},
}
}
// Deprecated: [0.116.0] Use xconsumererror.NewProfiles instead.
var NewProfiles = xconsumererror.NewProfiles
1 change: 1 addition & 0 deletions consumer/consumererror/xconsumererror/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../../Makefile.Common
36 changes: 36 additions & 0 deletions consumer/consumererror/xconsumererror/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module go.opentelemetry.io/collector/consumer/consumererror/xconsumererror

go 1.22.0

require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/consumer/consumererror v0.115.0
go.opentelemetry.io/collector/pdata/pprofile v0.115.0
go.opentelemetry.io/collector/pdata/testdata v0.115.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/pdata v1.21.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.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/pdata => ../../../pdata

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

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

replace go.opentelemetry.io/collector/consumer/consumererror => ../../consumererror
79 changes: 79 additions & 0 deletions consumer/consumererror/xconsumererror/go.sum

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

25 changes: 25 additions & 0 deletions consumer/consumererror/xconsumererror/signalerrors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package xconsumererror // import "go.opentelemetry.io/collector/consumer/consumererror/xconsumererror"

import (
"go.opentelemetry.io/collector/consumer/consumererror/internal"
"go.opentelemetry.io/collector/pdata/pprofile"
)

// Profiles is an error that may carry associated Profile data for a subset of received data
// that failed to be processed or sent.
type Profiles struct {
internal.Retryable[pprofile.Profiles]
}

// NewProfiles creates a Profiles that can encapsulate received data that failed to be processed or sent.
func NewProfiles(err error, data pprofile.Profiles) error {
return Profiles{
Retryable: internal.Retryable[pprofile.Profiles]{
Err: err,
Value: data,
},
}
}
46 changes: 46 additions & 0 deletions consumer/consumererror/xconsumererror/signalerrors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package xconsumererror // import "go.opentelemetry.io/collector/consumer/consumererror/xconsumererror"

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/pdata/testdata"
)

func TestProfiles(t *testing.T) {
td := testdata.GenerateProfiles(1)
err := errors.New("some error")
profileErr := NewProfiles(err, td)
assert.Equal(t, err.Error(), profileErr.Error())
var target Profiles
assert.False(t, errors.As(nil, &target))
assert.False(t, errors.As(err, &target))
require.ErrorAs(t, profileErr, &target)
assert.Equal(t, td, target.Data())
}

func TestProfiles_Unwrap(t *testing.T) {
td := testdata.GenerateProfiles(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Profiles.
profileErr := NewProfiles(err, td)
target := testErrorType{}
require.NotEqual(t, err, target)
// Unwrapping profileErr for err and assigning to target.
require.ErrorAs(t, profileErr, &target)
require.Equal(t, err, target)
}

type testErrorType struct {
s string
}

func (t testErrorType) Error() string {
return ""
}
4 changes: 2 additions & 2 deletions exporter/debugexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/config/configretry v1.21.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles v0.115.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.115.0 // indirect
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/extension v0.115.0 // indirect
Expand Down Expand Up @@ -94,7 +94,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con

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

replace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../consumer/consumererror/consumererrorprofiles
replace go.opentelemetry.io/collector/consumer/consumererror/xconsumererror => ../../consumer/consumererror/xconsumererror

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

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 @@ -9,7 +9,7 @@ require (
go.opentelemetry.io/collector/config/configretry v1.21.0
go.opentelemetry.io/collector/consumer v1.21.0
go.opentelemetry.io/collector/consumer/consumererror v0.115.0
go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles v0.115.0
go.opentelemetry.io/collector/consumer/consumererror/xconsumererror 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
Expand Down Expand Up @@ -67,7 +67,7 @@ replace go.opentelemetry.io/collector/exporter => ../../

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

replace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../../consumer/consumererror/consumererrorprofiles
replace go.opentelemetry.io/collector/consumer/consumererror/xconsumererror => ../../../consumer/consumererror/xconsumererror

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

Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/exporterhelperprofiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles"
"go.opentelemetry.io/collector/consumer/consumererror/xconsumererror"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand Down Expand Up @@ -54,7 +54,7 @@ func profilesRequestMarshaler(req exporterhelper.Request) ([]byte, error) {
}

func (req *profilesRequest) OnError(err error) exporterhelper.Request {
var profileError consumererrorprofiles.Profiles
var profileError xconsumererror.Profiles
if errors.As(err, &profileError) {
return newProfilesRequest(profileError.Data(), req.pusher)
}
Expand Down
Loading

0 comments on commit c6c249d

Please sign in to comment.