Skip to content

Commit af659fa

Browse files
rogercollbogdandrutuevan-bradley
authored
[service] Include component id/type in start error (#11837)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Wraps the component ID and type into the component's start retuned error. If `telemetry::logs::level` is < error (e.g fatal), the service error message does not give information about which pipeline component failed: Current error message: ``` $ otelcontribcol --config config.yaml Error: cannot start pipelines: start function error 2024/12/10 10:07:25 collector server run finished with error: cannot start pipelines: start function error ``` With these changes: ``` $ otelcontribcol --config config.yaml Error: cannot start pipelines: failed to start geoip processor: start function error 2024/12/10 09:58:29 collector server run finished with error: cannot start pipelines: failed to start geoip processor: start function error ``` <!-- Issue number if applicable --> #### Link to tracking issue #10426 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Bogdan Drutu <[email protected]> Co-authored-by: Evan Bradley <[email protected]>
1 parent 8cf42f3 commit af659fa

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'enhancement'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: include component id/type in start error
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10426]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

service/internal/graph/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func (g *Graph) StartAll(ctx context.Context, host *Host) error {
440440
zap.String("type", instanceID.Kind().String()),
441441
zap.String("id", instanceID.ComponentID().String()),
442442
)
443-
return compErr
443+
return fmt.Errorf("failed to start %q %s: %w", instanceID.ComponentID().String(), strings.ToLower(instanceID.Kind().String()), compErr)
444444
}
445445

446446
host.Reporter.ReportOKIfStarting(instanceID)

service/internal/graph/lifecycle_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestGraphStartStopComponentError(t *testing.T) {
162162
F: r1,
163163
T: e1,
164164
})
165-
require.EqualError(t, pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}), "foo")
165+
require.ErrorIs(t, pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}), r1.startErr)
166166
assert.EqualError(t, pg.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()), "bar")
167167
}
168168

@@ -432,7 +432,7 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) {
432432
}
433433
pg.componentGraph.SetEdge(simple.Edge{F: e0, T: e1})
434434

435-
assert.Equal(t, tt.startupErr, pg.StartAll(context.Background(), &Host{Reporter: rep}))
435+
require.ErrorIs(t, pg.StartAll(context.Background(), &Host{Reporter: rep}), tt.startupErr)
436436
assert.Equal(t, tt.shutdownErr, pg.ShutdownAll(context.Background(), rep))
437437
assertEqualStatuses(t, tt.expectedStatuses, actualStatuses)
438438
})

0 commit comments

Comments
 (0)