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

[bugfix] temporary fix around grpclogger #5272

Merged

Conversation

codeboten
Copy link
Contributor

Calling SetLoggerV2 isn't thread safe and should only be called before any grpc functions. See more details: https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/logging/settable#pkg-overview

This hacky workaround checks if the collector's logger has been set, if so, don't bother updating the grpc logger. Looking for alternative implementations here.

Calling SetLoggerV2 isn't thread safe and should only be called before
any grpc functions. See more details: https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/logging/settable#pkg-overview
@codeboten codeboten requested a review from a team as a code owner April 27, 2022 18:50
service/collector.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 27, 2022

Codecov Report

Merging #5272 (1aece5f) into main (f38e3e5) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5272      +/-   ##
==========================================
- Coverage   90.55%   90.53%   -0.02%     
==========================================
  Files         188      189       +1     
  Lines       11101    11116      +15     
==========================================
+ Hits        10052    10064      +12     
- Misses        827      829       +2     
- Partials      222      223       +1     
Impacted Files Coverage Δ
service/collector.go 75.90% <100.00%> (+0.14%) ⬆️
service/config_provider.go 75.67% <0.00%> (-14.41%) ⬇️
internal/testutil/testutil.go 72.72% <0.00%> (-1.85%) ⬇️
service/mapresolver.go 93.10% <0.00%> (ø)
pdata/internal/generated_pmetric.go 97.25% <0.00%> (+0.04%) ⬆️

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 f38e3e5...1aece5f. Read the comment docs.

This allows the InProcessCollector to prevent entering a race condition.
@@ -64,6 +64,9 @@ type CollectorSettings struct {
// LoggingOptions provides a way to change behavior of zap logging.
LoggingOptions []zap.Option

// SkipSettingGRPCLogger avoids setting the grpc logger
SkipSettingGRPCLogger bool
Copy link
Member

Choose a reason for hiding this comment

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

I might still be in need of a coffee, but how does this work? This is a new value, and I see this value only being read, never written, so, it will always be false. The conditional on service/collector.go would then always yield true, which will call the same code as before this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think it will be set in correctness tests, which are in the contrib repo, not in this repo.

BTW, I am not sure why we moved the all of the testbed from core to contrib. I consider the testbed to be a core part of the project. We run the testbed for otlp receiver/exporter in this repo, now we don't anymore and any problem discovery is delayed until the contrib consumes the new core.

Copy link
Member

Choose a reason for hiding this comment

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

I do agree that maybe the framework of testbed can live here, the reason we moved it was because we don't want to give API guarantees to the framework, and core is closer and closer to offer also API stability.

Copy link
Member

Choose a reason for hiding this comment

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

the reason we moved it was because we don't want to give API guarantees to the framework

That's a good point. Maybe we can keep testbed go module on 0.x forever to indicate it is unstable and also have explicit warning that no-one should use this API except contrib (yes, I know people don't pay attention to warnings :-) ).

@bogdandrutu bogdandrutu merged commit b34df3a into open-telemetry:main Apr 28, 2022
@codeboten codeboten deleted the codeboten/fix-race-condition branch April 28, 2022 14:46
@mx-psi
Copy link
Member

mx-psi commented Apr 28, 2022

This fixed #4971; It's a good temporary fix but I don't love this because I feel like it's yet another individual flag for customizing telemetry, and I would like to instead have something more general like the telemetry providers I proposed on #4970.

I haven't had time recently to push for that but I intend to continue the work there in the next few weeks, and would appreciate comments/thoughts/feedback from @codeboten and others who looked into this problem on that issue, to see if it is a good solution.

@codeboten
Copy link
Contributor Author

I'll take a look and provide feedback after today's release @mx-psi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants