-
Notifications
You must be signed in to change notification settings - Fork 399
feat(collector): add allow_startup_failure config option #1233
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
Merged
christos68k
merged 7 commits into
open-telemetry:main
from
rushabh-exe:rushabh-exe/allow-startup-failure
Mar 31, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a9d0e5a
feat(collector): add allow_startup_failure config option
rushabh-exe 27f07b4
address review feedback from @christos68k
rushabh-exe 5520ed8
refactor(collector): replace allow_startup_failure with error_mode
rushabh-exe a39e995
add Shutdown on startup failure and ErrorMode validation in Validate
rushabh-exe f042de1
added tests for ErrorMode UnmarshalText and Validate
rushabh-exe 1093f09
fix: move ErrorMode default to defaultConfig, add Start() and config …
rushabh-exe e835a71
fix: dummyReporter.Start return error for deterministic tests
rushabh-exe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,82 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //go:build linux && (amd64 || arm64) | ||
|
|
||
| package collector | ||
|
|
||
| import ( | ||
| "context" | ||
|
rushabh-exe marked this conversation as resolved.
|
||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| "go.opentelemetry.io/collector/component" | ||
| "go.opentelemetry.io/collector/component/componenttest" | ||
| "go.opentelemetry.io/collector/consumer/consumertest" | ||
| "go.opentelemetry.io/collector/consumer/xconsumer" | ||
| "go.opentelemetry.io/collector/receiver/receivertest" | ||
|
|
||
| "go.opentelemetry.io/ebpf-profiler/collector/config" | ||
| "go.opentelemetry.io/ebpf-profiler/libpf" | ||
| "go.opentelemetry.io/ebpf-profiler/reporter" | ||
| "go.opentelemetry.io/ebpf-profiler/reporter/samples" | ||
| ) | ||
|
|
||
| // dummyReporter is a no-op reporter for testing. | ||
| type dummyReporter struct{} | ||
|
|
||
| func (d *dummyReporter) Start(context.Context) error { return fmt.Errorf("dummy error") } | ||
| func (d *dummyReporter) Stop() {} | ||
| func (d *dummyReporter) ReportTraceEvent(*libpf.Trace, *samples.TraceEventMeta) error { return nil } | ||
|
|
||
| // TestStartErrorMode tests the error_mode config option on controller Start(). | ||
| // dummyReporter.Start() always returns an error to simulate startup failure. | ||
| func TestStartErrorMode(t *testing.T) { | ||
| dummyFactory := func(_ *reporter.Config, _ xconsumer.Profiles) (reporter.Reporter, error) { | ||
| return &dummyReporter{}, nil | ||
| } | ||
|
|
||
| for _, tt := range []struct { | ||
| name string | ||
| errorMode config.ErrorMode | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "propagate returns error", | ||
| errorMode: config.PropagateError, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "ignore returns nil", | ||
| errorMode: config.IgnoreError, | ||
| wantErr: false, | ||
| }, | ||
| } { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| cfg := defaultConfig().(*config.Config) | ||
| cfg.ErrorMode = tt.errorMode | ||
| cfg.NoKernelVersionCheck = true | ||
|
|
||
| typ, err := component.NewType("test") | ||
| require.NoError(t, err) | ||
|
|
||
| recv, err := BuildProfilesReceiver( | ||
| WithReporterFactory(dummyFactory), | ||
| )( | ||
| t.Context(), | ||
| receivertest.NewNopSettings(typ), | ||
| cfg, | ||
| consumertest.NewNop(), | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| err = recv.Start(t.Context(), componenttest.NewNopHost()) | ||
| if tt.wantErr { | ||
| require.Error(t, err) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.