-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate consumererrorprofiles module in favor of xconsumererror (#1…
- Loading branch information
Showing
19 changed files
with
236 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
46
consumer/consumererror/xconsumererror/signalerrors_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.