opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

Improve logging of component start errors

Open swiatekm opened this issue 1 year ago • 1 comments

Description

Improved logging of component start errors, so the log lines appear where they chronologically happen, rather than at the end. They also use the component logger, which makes them look nicer.

Output before change:

2024-06-19T14:15:30.822+0200    info    [email protected]/service.go:115 Setting up own telemetry...
2024-06-19T14:15:30.822+0200    info    [email protected]/telemetry.go:96        Serving metrics {"address": ":8888", "level": "Normal"}
2024-06-19T14:15:30.823+0200    info    [email protected]/service.go:182 Starting otelcorecol... {"Version": "0.103.0-dev", "NumCPU": 32}
2024-06-19T14:15:30.823+0200    info    extensions/extensions.go:35     Starting extensions...
2024-06-19T14:15:30.823+0200    info    [email protected]/service.go:245 Starting shutdown...
2024-06-19T14:15:30.823+0200    info    extensions/extensions.go:61     Stopping extensions...
2024-06-19T14:15:30.823+0200    info    [email protected]/service.go:259 Shutdown complete.
Error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found
2024/06/19 14:15:30 collector server run finished with error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found

Output after change:

2024-06-19T14:25:18.324+0200    info    [email protected]/service.go:115 Setting up own telemetry...
2024-06-19T14:25:18.325+0200    info    [email protected]/telemetry.go:96        Serving metrics {"address": ":8888", "level": "Normal"}
2024-06-19T14:25:18.326+0200    info    [email protected]/service.go:182 Starting otelcorecol... {"Version": "0.103.0-dev", "NumCPU": 32}
2024-06-19T14:25:18.326+0200    info    extensions/extensions.go:35     Starting extensions...
2024-06-19T14:25:18.326+0200    error   graph/graph.go:428      Failed to start component       {"error": "failed to resolve authenticator \"oauth2client\": authenticator not found", "type": "Exporter", "id": "otlphttp"}
2024-06-19T14:25:18.326+0200    info    [email protected]/service.go:245 Starting shutdown...
2024-06-19T14:25:18.326+0200    info    extensions/extensions.go:61     Stopping extensions...
2024-06-19T14:25:18.326+0200    info    [email protected]/service.go:259 Shutdown complete.
Error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found
2024/06/19 14:25:18 collector server run finished with error: cannot start pipelines: failed to resolve authenticator "oauth2client": authenticator not found

We've added the following line:

2024-06-19T14:25:18.326+0200    error   graph/graph.go:428      Failed to start component       {"error": "failed to resolve authenticator \"oauth2client\": authenticator not found", "type": "Exporter", "id": "otlphttp"}

For extensions, the new line looks like so:

2024-06-25T16:59:18.513+0200    error    extensions/extensions.go:54     Failed to start extension      {"kind": "extension", "name": "memory_limiter", "error": "failed to get memory limit"}

Link to tracking issue

Fixes #7078

swiatekm avatar Jun 19 '24 13:06 swiatekm

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.33%. Comparing base (2d51bc4) to head (6157936).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10440   +/-   ##
=======================================
  Coverage   92.33%   92.33%           
=======================================
  Files         403      403           
  Lines       18725    18733    +8     
=======================================
+ Hits        17289    17297    +8     
  Misses       1076     1076           
  Partials      360      360           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 19 '24 13:06 codecov[bot]

Can you fix CI? After that I am happy to merge this

mx-psi avatar Jul 18 '24 13:07 mx-psi

Can you fix CI? After that I am happy to merge this

Rebased on main after #10661, should be enough.

swiatekm avatar Jul 18 '24 13:07 swiatekm