-
Notifications
You must be signed in to change notification settings - Fork 773
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
Remove interfaces used for creating mock gRPC clients #2831
Remove interfaces used for creating mock gRPC clients #2831
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2831 +/- ##
==========================================
+ Coverage 83.72% 83.73% +0.01%
==========================================
Files 251 251
Lines 8866 8866
==========================================
+ Hits 7423 7424 +1
+ Misses 1443 1442 -1
|
@alanwest looks like the CI is failing. (I retried and still the same) |
Hmm, I ran it once again and it worked... though we may have a bug hiding somewhere (not related to this PR) Found this in the log of one of the failed runs
|
@alanwest do you have the link to the failed run and test case? I can take a look. I guess it might be related to some race condition that the exporter got disposed before the exporting thread joined. The exception callstack suggested that The safe handle used by the events were owned by the exporter instance, and is disposed here opentelemetry-dotnet/src/OpenTelemetry/BatchExportProcessor.cs Lines 211 to 220 in 102ac27
The exporter shutdown logic is making a time-bound invocation on worker thread's opentelemetry-dotnet/src/OpenTelemetry/BatchExportProcessor.cs Lines 191 to 197 in 102ac27
opentelemetry-dotnet/src/OpenTelemetry/BatchExportProcessor.cs Lines 204 to 207 in 102ac27
If the test case is not giving the exporter sufficient time to join the worker thread, the events could be disposed while the worker thread is still running. We could in theory swallow these exceptions and check if shutdown already happened though. |
Failed run: https://github.com/open-telemetry/opentelemetry-dotnet/runs/5028395785?check_suite_focus=true It's unclear exactly which test case it failed on but the surrounding passing test cases suggests it may be
|
Thanks! That's sufficient for me to look into the problem 💪 |
My primary intent with this PR is to enable the move of the generated proto code to its own package. Something like
OpenTelemetry.Proto
. The OTLP exporter package would then depend onOpenTelemetry.Proto
rather than generating the code itself.The interfaces we've introduced for testing purposes cause a wrinkle in this effort. The issue is that you can't extend a partial class from another assembly. So, in this case we're extending
[Metric|Log|Trace]ServiceClient
in order to introduce an interface.As it turns out, we're not actually making very extensive use of these interfaces (I think we were more so before). Furthermore, they're internal. I think we should remove them.
Docs for gRPC .NET essentially just guide folks to use a mocking library https://docs.microsoft.com/en-us/aspnet/core/grpc/test-client?view=aspnetcore-6.0#mock-a-grpc-client.
The only place remaining where we need to mock the client is in the benchmark project, so I've demonstrated things there. Might be nice to centralize this "get me a mock gRPC client" code somewhere if we end up needing to do the same thing in other tests.