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

feat: Add support for ASP.NET Core gRPC #563

Merged
merged 8 commits into from
Nov 1, 2020
Merged

feat: Add support for ASP.NET Core gRPC #563

merged 8 commits into from
Nov 1, 2020

Conversation

Mitch528
Copy link
Contributor

No description provided.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

There's a lot of good stuff here @Mitch528 thank you.
The general architecture though I believe can't get merged in its current form. It's too much duplication from ASP.NET Core and I think we can redo this in a way that it hooks into the current ASP.NET Core integration. Without having to take over the hook UseSentry. The docs would then refer to: Add Sentry.AspNetCore.Grpc and add AddGrpc to the callback, or add something DI or whatever.

Would you be willing to make the changes necessary?

samples/Sentry.Samples.AspNetCore.Grpc/Program.cs Outdated Show resolved Hide resolved
_ = services.AddSingleton<ISentryEventProcessor, AspNetCoreEventProcessor>();
services.TryAddSingleton<IUserFactory, DefaultUserFactory>();

_ = services.AddSingleton<IProtobufRequestPayloadExtractor, DefaultProtobufRequestPayloadExtractor>();
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
_ = services.AddSingleton<IProtobufRequestPayloadExtractor, DefaultProtobufRequestPayloadExtractor>();
_ = services.AddSingleton<IProtobufRequestPayloadExtractor, DefaultProtobufRequestPayloadExtractor>();

Looks like instead of copying the whole ASP.NET Core integration, all we need is this line ^, and the one below:

    services.AddGrpc(options =>
            {
                options.Interceptors.Add<SentryGrpcInterceptor>();
            });

Besides these, the code that goes in the middleware etc...

This integration could be be done differently then, we could offer a single entrypoint, and add it like:

UseSentry(o => o.AddGrpc()

And through that extension method we find the right hooks, like adding stuff into DI and the middleware.

@Mitch528
Copy link
Contributor Author

@bruno-garcia I think I resolved the issues you had with the code, but let me know if you need me to make any more changes.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Yeah this looks great now! Thanks!
I left two nits out but we're almost there.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;net5.0</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need net5.0 here? Wouldn't netcoreapp3.0 be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably should be good with just netcoreapp3.0. I'll change it.

src/Sentry.AspNetCore.Grpc/SentryGrpcInterceptor.cs Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Oct 30, 2020

Codecov Report

Merging #563 into main will decrease coverage by 21.88%.
The diff coverage is 23.56%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #563       +/-   ##
===========================================
- Coverage   85.06%   63.18%   -21.89%     
===========================================
  Files         142      176       +34     
  Lines        3462     4965     +1503     
  Branches      775      852       +77     
===========================================
+ Hits         2945     3137      +192     
- Misses        310     1602     +1292     
- Partials      207      226       +19     
Impacted Files Coverage Δ
...ore.Grpc/DefaultProtobufRequestPayloadExtractor.cs 0.00% <0.00%> (ø)
src/Sentry.AspNetCore.Grpc/GrpcRequestAdapter.cs 0.00% <0.00%> (ø)
...etCore.Grpc/ProtobufRequestExtractionDispatcher.cs 0.00% <0.00%> (ø)
src/Sentry.AspNetCore.Grpc/ScopeExtensions.cs 0.00% <0.00%> (ø)
...rc/Sentry.AspNetCore.Grpc/SentryGrpcInterceptor.cs 24.70% <24.70%> (ø)
...entry.AspNetCore/SentryWebHostBuilderExtensions.cs 88.46% <57.14%> (-11.54%) ⬇️
.../Sentry.AspNetCore.Grpc/SentryBuilderExtensions.cs 71.42% <71.42%> (ø)
src/Sentry.AspNetCore/SentryAspNetCoreBuilder.cs 75.00% <75.00%> (ø)
...DependencyInjection/ServiceCollectionExtensions.cs 100.00% <100.00%> (ø)
src/Sentry.AspNetCore/SentryBuilderExtensions.cs 100.00% <100.00%> (ø)
... and 52 more

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 5259ffd...e78dc4f. Read the comment docs.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

This is a great addition! Thanks a lot @Mitch528

@bruno-garcia bruno-garcia merged commit daab2cc into getsentry:main Nov 1, 2020
@bruno-garcia
Copy link
Member

@Mitch528
Copy link
Contributor Author

Mitch528 commented Nov 2, 2020

@bruno-garcia Awesome! 🎉

@Mitch528 Mitch528 deleted the feat/grpc branch November 2, 2020 18:06
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.

4 participants