-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Use provider type name for CodeAction telemetry for code actions... #60480
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
Conversation
…ted through CodeAction.Create factory methods Fixes dotnet#4919 Currently, we always use the CodeAction's full type name to generate the telemetry ID to log for applied code actions. This is reasonable for special CodeActions that sub-type the CodeAction type and have custom logic. However, majority of fixers and refactorings do not need special CodeAction sub-type and can/should use the CodeAction.Create factory methods to create the code actions to register. Until now, these providers were forced to create a dummy nested type (generally named MyCodeAction) and use it to allow telemetry to capture the outer type's full type name. With this change, we now keep track of whether a CodeAction was created with a factory method or not. If it was created with a factory method, then we use the registering fixer/refactoring provider's full type name for telemetry. Otherwise, we use the CodeAction's full type name. Additionally, we also append the EquivalenceKey in the telemetry ID in both the cases, which should allow multiple code actions registered by the same fixer/refactoring to be differentiated. NOTE: I will create a follow-up PRs in both Roslyn and Roslyn-Analyzers repos to delete all the stub MyCodeAction types once this goes in.
Should this really be done for roslyn-analyzers if Microsoft.CodeAnalysis packages isn't updated to latest? |
I don’t believe anyone is actively looking at CodeFixer telemetry to be affected if we have a small intermediate period without useful telemetry. So I think we should be fine. Also note that the analyzer package itself doesn’t need to move to reference newer MS.CA packages as there are no public API changes here. |
|
Will this mean we can get rid of all our 'MyCideAction' subclasses? |
For 99.99% of the cases yes (per my understanding). The 0.01% are cases like this where the subclass does something useful: Lines 255 to 276 in 1f2d474
|
|
Yes, agree with @Youssef1313 |
|
Great. That makes me super happy. |
|
Nevermind, not sure how I missed it. |
|
Thanks @mavasani! No issues with the PR, will just need to remember to keep both kinds of maps in our queries so we don't drop stuff from before this change goes in. |
src/Workspaces/CoreTest/Shared/Extensions/TelemetryExtensions/TelemetryExtensionTests.cs
Show resolved
Hide resolved
Actually, good observation. I have done partial fixes to that tool, but can get it fully working again only after I am able to cleanup and remove the MyCodeAction nested types. More changes to the tool are coming in the next PR. |
|
@mavasani There is an unrelated failure here. Can you restart it so the PR can be merged? |
Follow up to dotnet#60480. The above PR led to us logging provider name instead of code action name in the telemetry when provider is using CodeAction.Create helper to create a code action. This broke the CodeActionDescriptionMap within the BuildActionTelemetryTable tool that is used to search for code action telemetry in Kusto. This PR regenerates the CodeActionDescriptionMap. I have added a helper method to the tool which can be used when required to regenerate this description map in future.
Follow up to dotnet#60480. The above PR led to us logging provider name instead of code action name in the telemetry when provider is using CodeAction.Create helper to create a code action. This broke the CodeActionDescriptionMap within the BuildActionTelemetryTable tool that is used to search for code action telemetry in Kusto. This PR regenerates the CodeActionDescriptionMap. I have added a helper method to the tool which can be used when required to regenerate this description map in future.
Follow up to dotnet#60480. The above PR led to us logging provider name instead of code action name in the telemetry when provider is using CodeAction.Create helper to create a code action. This broke the CodeActionDescriptionMap within the BuildActionTelemetryTable tool that is used to search for code action telemetry in Kusto. This PR regenerates the CodeActionDescriptionMap. I have added a helper method to the tool which can be used when required to regenerate this description map in future.
Follow up to dotnet#60480. The above PR led to us logging provider name instead of code action name in the telemetry when provider is using CodeAction.Create helper to create a code action. This broke the CodeActionDescriptionMap within the BuildActionTelemetryTable tool that is used to search for code action telemetry in Kusto. This PR regenerates the CodeActionDescriptionMap. I have added a helper method to the tool which can be used when required to regenerate this description map in future.
...created through
CodeAction.Createfactory methodsIt only took 7 years, but...
Fixes #4919
Currently, we always use the CodeAction's full type name to generate the telemetry ID to log for applied code actions. This is reasonable for special CodeActions that sub-type the CodeAction type and have custom logic. However, majority of fixers and refactorings do not need special CodeAction sub-type and can/should use the CodeAction.Create factory methods to create the code actions to register. Until now, these providers were forced to create a dummy nested type (generally named MyCodeAction) and use it to allow telemetry to capture the outer type's full type name.
With this change, we now keep track of whether a CodeAction was created with a factory method or not. If it was created with a factory method, then we use the registering fixer/refactoring provider's full type name for telemetry. Otherwise, we use the CodeAction's full type name. Additionally, we also append the EquivalenceKey in the telemetry ID in both the cases, which should allow multiple code actions registered by the same fixer/refactoring to be differentiated.
NOTE: I will create a follow-up PRs in both Roslyn and Roslyn-Analyzers repos to delete all the stub MyCodeAction types once this goes in.