forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[consumer] Add new consumererrorprofiles module (open-telemetry#11207)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Split off from open-telemetry#11131. Adds new module for consumer errors for profiles. --------- Co-authored-by: Damien Mathieu <[email protected]>
- Loading branch information
1 parent
223de3e
commit a1b324e
Showing
10 changed files
with
256 additions
and
28 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,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: consumererrorprofiles | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add new module consumereerrorprofiles for consumer error profiles. | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [11131] | ||
|
||
# (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] |
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/consumererrorprofiles | ||
|
||
go 1.22.0 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.9.0 | ||
go.opentelemetry.io/collector/consumer v0.109.0 | ||
go.opentelemetry.io/collector/pdata/pprofile v0.111.0 | ||
go.opentelemetry.io/collector/pdata/testdata v0.111.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.17.0 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/sys v0.24.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect | ||
google.golang.org/grpc v1.67.1 // indirect | ||
google.golang.org/protobuf v1.35.1 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace go.opentelemetry.io/collector/consumer => ../.. | ||
|
||
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
consumer/consumererror/consumererrorprofiles/signalerrors.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,25 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package consumererrorprofiles // import "go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles" | ||
|
||
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/consumererrorprofiles/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 consumererrorprofiles // import "go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles" | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package internal // import "go.opentelemetry.io/collector/consumer/consumererror/internal" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/pdata/plog" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/pdata/pprofile" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
type Retryable[V ptrace.Traces | pmetric.Metrics | plog.Logs | pprofile.Profiles] struct { | ||
Err error | ||
Value V | ||
} | ||
|
||
// Error provides the error message | ||
func (err Retryable[V]) Error() string { | ||
return err.Err.Error() | ||
} | ||
|
||
// Unwrap returns the wrapped error for functions Is and As in standard package errors. | ||
func (err Retryable[V]) Unwrap() error { | ||
return err.Err | ||
} | ||
|
||
// Data returns the telemetry data that failed to be processed or sent. | ||
func (err Retryable[V]) Data() V { | ||
return err.Value | ||
} |
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