Skip to content
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

Fix panic when telemetry metrics are disabled #5642

Merged
merged 7 commits into from
Jul 8, 2022

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Jul 7, 2022

Description: Fix panic when telemetry::metrics::level is set to none.

Link to tracking Issue: Fixes #5641

Testing: Add unit test for avoiding regressions

@mx-psi
Copy link
Member Author

mx-psi commented Jul 7, 2022

As seen in the CI logs the unit test reproduces the crash

@mx-psi mx-psi marked this pull request as ready for review July 7, 2022 09:20
@mx-psi mx-psi requested review from a team and codeboten July 7, 2022 09:20
@codecov
Copy link

codecov bot commented Jul 7, 2022

Codecov Report

Merging #5642 (603b943) into main (feab949) will increase coverage by 0.08%.
The diff coverage is 40.00%.

@@            Coverage Diff             @@
##             main    #5642      +/-   ##
==========================================
+ Coverage   91.33%   91.41%   +0.08%     
==========================================
  Files         191      191              
  Lines       11384    11386       +2     
==========================================
+ Hits        10398    10409      +11     
+ Misses        786      778       -8     
+ Partials      200      199       -1     
Impacted Files Coverage Δ
service/service.go 63.41% <40.00%> (+0.91%) ⬆️
service/telemetry.go 89.20% <0.00%> (+6.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update feab949...603b943. Read the comment docs.

@mx-psi mx-psi requested a review from jpkrohling July 7, 2022 13:19
@mx-psi mx-psi requested a review from TylerHelmuth July 7, 2022 15:58
Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

service/collector_test.go Outdated Show resolved Hide resolved
service/host_test.go.bak Outdated Show resolved Hide resolved
@mx-psi mx-psi requested a review from Aneurysm9 July 7, 2022 16:27
// The process telemetry initialization requires the ballast size, which is available after the extensions are initialized.
if err = telemetry.RegisterProcessMetrics(srv.telemetryInitializer.ocRegistry, getBallastSize(srv.host)); err != nil {
return nil, fmt.Errorf("failed to register process metrics: %w", err)
if set.Config.Telemetry.Metrics.Level != configtelemetry.LevelNone && set.Config.Telemetry.Metrics.Address != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect an empty address to return a validation error, instead of silently disabling telemetry. Do you think this is worth an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I can open an issue for that, I would also expect an empty address to make it fail. (I didn't mention this in the PR but this check comes from

if cfg.Metrics.Level == configtelemetry.LevelNone || cfg.Metrics.Address == "" {
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yeah I eventually tracked down the same check :D

@codeboten codeboten merged commit 58e66af into open-telemetry:main Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collector panics if setting metrics level to 'none'
5 participants