-
Notifications
You must be signed in to change notification settings - Fork 305
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
Fix AOT warnings in StackExchangeRedis #1415
Conversation
- Add net6.0 target, so we can annotate the code correctly and use new APIs. - Copy PropertyFetcher from open-telemetry/opentelemetry-dotnet-contrib which was made AOT compatible. Made a new shared version that other libraries can opt into using over time, so this change has no affect on other libraries. - Add StackExchangeRedis to the AotCompatibility.TestApp. - Address warnings to make the code work under AOT/trimmed. Fix open-telemetry#1341
Codecov Report
@@ Coverage Diff @@
## main #1415 +/- ##
==========================================
- Coverage 73.91% 73.69% -0.22%
==========================================
Files 267 261 -6
Lines 9615 9631 +16
==========================================
- Hits 7107 7098 -9
- Misses 2508 2533 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
|
...y.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs
Show resolved
Hide resolved
...y.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj
Show resolved
Hide resolved
test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj
Show resolved
Hide resolved
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.
Please add a CHANGELOG entry.
I've addressed all existing feedback. I believe this PR is ready for review. |
|
||
if (declaringType == typeof(object)) | ||
{ | ||
// TODO: REMOVE this if branch when .NET 7 is out of support. |
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.
net7.0 is not one of the target for the project currently:
https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1415/files#:~:text=%3CTargetFrameworks%3Enet6.0%3Bnetstandard2.0%3Bnet462%3C/TargetFrameworks%3E
Do we need this 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.
I would like this to be a straight copy from opentelemetry-dotnet. Then we can keep the 2 in sync over time.
Also, the reason this code is here isn't in case one of the libraries targets net7.0, its for when the application targets net7.0, which we can't control here.
LGTM. Left a nit comment. Thanks! |
This brings in AOT support open-telemetry/opentelemetry-dotnet-contrib#1415
This brings in AOT support open-telemetry/opentelemetry-dotnet-contrib#1415
This brings in AOT support open-telemetry/opentelemetry-dotnet-contrib#1415
open-telemetry#1415 had an issue in it due to how the DynamicDependency attribute is written. 1. Referring to a nested type with `+` isn't correct in DynamicDependency attributes. You need to just use a normal `.`. The current code is producing a warning when using the .NET 8.0 SDK to publish for AOT. "warning IL2036: OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation.RedisProfilerEntryToActivityConverter.<.cctor>g__GetCommandAndKey|5_3(PropertyFetcher`1<String>,Object,String&): Unresolved type 'StackExchange.Redis.RedisDatabase+ScriptEvalMessage' in 'DynamicDependencyAttribute'." This wasn't caught in our CI because we use the .NET 7.0 SDK to publish, which doesn't catch this bug. 2. The "CommandAndKey" property isn't on the nested ScriptEvalMessage type, but instead a virtual on the base Message class. The fix here is to use the base Message class in the DynamicDependency. I've verified this works with a .NET 8.0 SDK.
Fix #1341
cc @Yun-Ting @utpilla @vitek-karas