Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[AOT] Remove usage of Linq.Expressions and especially lambda compilation #4695
[AOT] Remove usage of Linq.Expressions and especially lambda compilation #4695
Changes from 1 commit
5120526
1fdd8ee
d041885
132003d
0a2a105
4985d8d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I spoke to @tarekgh about this, and asked why these setters aren't exposed publicly (since OpenTelemetry needs to call them), he told me that these setters only need to be called on
< net7.0
runtimes. If you look at the callsites, you'll see this is true for 2 of the 3 callsites:opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Lines 195 to 198 in 0343116
opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs
Lines 161 to 165 in 0343116
And in Grpc, it always calls it:
opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs
Lines 124 to 127 in 0343116
I think the correct thing to do here is to not compile this code on
net7.0+
TFMs, and then fix the 2 places above to have#if !NET7_0_OR_GREATER
checks around them that don't already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@utpilla do you agree to change GRPC to not call these on net7.0+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an additional complication - it would require adding
net7.0
as a TFM to Http and Grcp instrumentation assemblies. Http currently uses a boolean which is determined by looking at version of theSystem.Net.Http
assembly, the trimmer would not be able to figure this out. I don't think we have a runtime property which the trimmer will know a constant value of and can be used to determine the version.Additionally, Grpc package is currently
netstandard2.0
/netstandard2.1
only... we will probably have to change that anyway (to get the annotation attributes), but by default it would only getnet6.0
, notnet7.0
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+@noahfalk as an "fyi".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @cijothomas @reyang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Older versions of aspnet and http client used to create the
Activity
objects the legacy way usingnew Activity
. OpenTelemetry wanted to support these old versions of such platforms which needed to setKind
properly on such activity. This was the need for reflection. Aspnet and http client then moved (in .NET 7.0) to create the Activity object usingActivitySource
which set theKind
correctly on the createdActivity
object so there was no need to do anything more with such objects or use the reflection.I don't know gRPC scenarios. If it is same as aspnet then there is no need to call reflection on .NET 7.0+.
@cijothomas you were the one implementing that as I recall if you have more input here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it isn't following this guidance of using
ActivitySource.CreateActivity/StartActivity
. 😢 For either it's own Activity:https://github.com/grpc/grpc-dotnet/blob/0ab3ada34aa76740b436b3b1d320f2f406f82f50/src/Grpc.Net.Client/Internal/GrpcCall.cs#L823
nor its copy of the HTTP
System.Net.Http.HttpRequestOut
Activity:https://github.com/grpc/grpc-dotnet/blob/0ab3ada34aa76740b436b3b1d320f2f406f82f50/src/Shared/TelemetryHeaderHandler.cs#L70
Maybe someone should log an issue on the gRPC client to move away from the "legacy way
new Activity(...)
" and use an ActivitySource. Then OpenTelemetry wouldn't need to use reflection here at all.cc @JamesNK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc-dotnet was written for .NET Core 3, and
ActivitySource
didn't exist then. grpc-dotnet still targets .NET Core 3 + .NET 5, but I'm going to drop the unsupported targets for .NET 8.Grpc.Net.Client also targets netstandard2.0, but ActivitySource is in the System.Diagnostics.DiagnosticSource NuGet package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: grpc/grpc-dotnet#2180 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR: grpc/grpc-dotnet#2244