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

Fix up Redis trimming annotations #1420

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

eerhardt
Copy link
Contributor

#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,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.

  1. 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.

cc @Yun-Ting @utpilla @vitek-karas

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.
@eerhardt eerhardt requested a review from a team October 31, 2023 22:41
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Merging #1420 (a2e13ca) into main (71655ce) will decrease coverage by 2.55%.
Report is 43 commits behind head on main.
The diff coverage is 6.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1420      +/-   ##
==========================================
- Coverage   73.91%   71.37%   -2.55%     
==========================================
  Files         267        5     -262     
  Lines        9615      269    -9346     
==========================================
- Hits         7107      192    -6915     
+ Misses       2508       77    -2431     
Flag Coverage Δ
unittests-Instrumentation.StackExchangeRedis 71.37% <6.45%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...dis/StackExchangeRedisConnectionInstrumentation.cs 95.58% <100.00%> (-1.48%) ⬇️
...mentation/RedisProfilerEntryToActivityConverter.cs 39.13% <0.00%> (-40.67%) ⬇️

... and 259 files with indirect coverage changes

@Yun-Ting
Copy link
Contributor

maybe add a unit test to cover this case?

@eerhardt
Copy link
Contributor Author

maybe add a unit test to cover this case?

Do we have unit tests that actually publish the trimmed/AOT'd app and run it?

This bug would have been caught if we used the .NET 8.0 SDK in the verify-aot-compat leg instead of the 7.0 SDK. Do you know when that will happen? After 8.0 RTM ships?

@utpilla utpilla added the comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis label Nov 1, 2023
@utpilla utpilla merged commit 28906fb into open-telemetry:main Nov 1, 2023
@eerhardt eerhardt deleted the FixUpRedisAOTAnnotations branch November 1, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants