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

[service] Fix panic when not using NewCommand #4139

Merged
merged 7 commits into from
Sep 30, 2021

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Sep 28, 2021

Description:

  • Reorder tests to trigger bug
  • Add default value to flags

Link to tracking Issue: Fixes #4138

Testing: Reordered tests to trigger the panic

@mx-psi

This comment has been minimized.

@bogdandrutu
Copy link
Member

@mx-psi it is still expected to crash since the issue #4138 is not yet resolved, but I believe this is good to speed-up that issue.

The test does not trigger this panic since it is using a custom provider,
but for consistency we can change it there too.
@mx-psi

This comment has been minimized.

@mx-psi mx-psi marked this pull request as ready for review September 28, 2021 14:30
@mx-psi mx-psi requested review from a team and owais September 28, 2021 14:30
@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #4139 (db35aea) into main (afad36e) will not change coverage.
The diff coverage is 70.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4139   +/-   ##
=======================================
  Coverage   87.66%   87.66%           
=======================================
  Files         174      174           
  Lines       10224    10224           
=======================================
  Hits         8963     8963           
  Misses       1011     1011           
  Partials      250      250           
Impacted Files Coverage Δ
service/internal/telemetrylogs/logger.go 71.42% <50.00%> (ø)
internal/collector/telemetry/telemetry.go 100.00% <100.00%> (ø)
service/flags.go 72.00% <100.00%> (ø)

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 afad36e...db35aea. Read the comment docs.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

Does this fully fix #4138 or there is more work to do? If fixed would be nice to add a test to show it is fixed.

@mx-psi
Copy link
Member Author

mx-psi commented Sep 29, 2021

Does this fully fix #4138 or there is more work to do?

Yes, the example program does not crash at startup and in general this class of crashes should be gone.

If fixed would be nice to add a test to show it is fixed.

I thought I needed to do more work to work around collectorTelemetry for adding a test, but it was easier than I expected, added in the last commit :)

Comment on lines +32 to +33
metricsAddrPtr = &metricsAddrDefault
metricsPrefixPtr = &metricsPrefixDefault
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
metricsAddrPtr = &metricsAddrDefault
metricsPrefixPtr = &metricsPrefixDefault
metricsAddrPtr = new(string)
metricsPrefixPtr = new(string)

Would this be safer? Does anything use the default value that might break if it changes when the user specifies this value via CLI flags?

Copy link
Member Author

Choose a reason for hiding this comment

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

On this particular instance it would be fine to just use new, but on the logs side it's not

func logDeprecatedMessages(logger *zap.Logger) {
if *loggerLevelPtr != "deprecated" {
logger.Warn("`log-level` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}
if *loggerProfilePtr != "deprecated" {
logger.Warn("`log-profile` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}
if *loggerFormatPtr != "deprecated" {
logger.Warn("`log-format` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}
}
since you need the value to be "deprecated". I would prefer to leave it like this for consistency

@bogdandrutu bogdandrutu merged commit b2631ec into open-telemetry:main Sep 30, 2021
@mx-psi mx-psi deleted the mx-psi/fix-panic branch September 30, 2021 15:11
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.

Running the Collector panics if service.NewCommand is not called first
4 participants