-
Notifications
You must be signed in to change notification settings - Fork 199
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
Add CLaSP Request Tracking #11015
Add CLaSP Request Tracking #11015
Conversation
/// of this class corresponds to a specific FunctionId operation and can support aggregated values for each | ||
/// metric name logged. | ||
/// </summary> | ||
internal sealed class AggregatingTelemetryLog |
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.
This is taken from Roslyn and adapted to how we do telemetry
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.
Should this be a comment in the code so that we can refer back to the original implementation later on?
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 can add a comment with a permalink. The implementation itself is fairly straight forward so I wasn't sure it was needed, but I wanted to give context on where I got it for the PR.
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.
For sure, I just wondered if we wanted to capture the place to go look if we have questions or to see any updates.
/// <summary> | ||
/// Manages creation and obtaining aggregated telemetry logs. | ||
/// </summary> | ||
internal sealed class AggregatingTelemetryLogManager : IDisposable |
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 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.
@dibarbet has a PR out removing the roslyn version of this class. You might want to coordinate with him before duplicating it.
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.
Same question as before. Is this better placed in the code to make that connection with the Roslyn code a bit more permanent? If so, please use a permanent link in case the Roslyn file gets moved.
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Outdated
Show resolved
Hide resolved
public override void RecordWarning(string message) | ||
{ | ||
_exception = new Exception(message); | ||
_result = TelemetryResult.Failed; |
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.
Whats the scenario for this? It's a little odd for "Warning" and "Failed" to be mixed. They don't mean the same thing to me. Should this be RecordFailure
or RecordError
? Even perhaps RecordException
, but its just the convenience overload you can call if you just have a string.
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 agree. Capturing an exception for a warning and marking it as "failed" is surprising to me.
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 think I'm going to remove the exception entirely. It's provided, but we don't record it in a normal histogram related way. It should get caught through fault reporting through
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CLaSPTelemetryService.cs
Outdated
Show resolved
Hide resolved
/// of this class corresponds to a specific FunctionId operation and can support aggregated values for each | ||
/// metric name logged. | ||
/// </summary> | ||
internal sealed class AggregatingTelemetryLog |
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.
Should this be a comment in the code so that we can refer back to the original implementation later on?
/// <summary> | ||
/// Manages creation and obtaining aggregated telemetry logs. | ||
/// </summary> | ||
internal sealed class AggregatingTelemetryLogManager : IDisposable |
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.
Same question as before. Is this better placed in the code to make that connection with the Roslyn code a bit more permanent? If so, please use a permanent link in case the Roslyn file gets moved.
...rc/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/AggregatingTelemetryLogManager.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Show resolved
Hide resolved
@@ -5,7 +5,7 @@ | |||
|
|||
namespace Microsoft.AspNetCore.Razor.Telemetry; | |||
|
|||
internal interface ITelemetryReporter | |||
internal interface ITelemetryReporter : IDisposable |
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.
Does this interface need to be IDisposable
? Or, is it sufficient to mark TelemetryReporter
as IDisposable
? AFAICT, this isn't needed by the ITelemetryReporter
contract itself and results in a do-nothing Dispose()
on NoOpTelemetryReporter
.
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.
This is where my knowledge gets a little iffy. Disposal is handled by the DI implementation, and it's added as a singleton with AddSingleton<ITelemetryReporter>
. Does DI know if the underlying class needs to be disposed? Do I need to add a finalizer pattern with disposal?
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.
Yes, all the DI containers we use -- MEF, Microsoft.Extensions.DependencyInjection, VSMEF -- will dispose the runtime object if it implements IDisposable
. It is not necessary for the contract interface to be IDisposable
. (Actually, it would be pretty weird if that was a requirement!)
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 just have blissful ignorance for MEF and VSMEF :) Will move IDisposable down
src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Telemetry/ITelemetryReporter.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Telemetry/TelemetryReporter.cs
Outdated
Show resolved
Hide resolved
|
||
namespace Microsoft.AspNetCore.Razor.LanguageServer; | ||
|
||
internal class CLaSPTelemetryService(ITelemetryReporter telemetryReporter) : AbstractTelemetryService |
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 guess, consider marking this sealed too. 😄
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.
:)
@@ -165,6 +165,7 @@ protected override ILspServices ConstructLspServices() | |||
// TelemetryService.SetDefaultSession and provides the correct | |||
// appinsights keys etc |
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.
Is this comment in the right place? It's not clear to me what code it's referring to.
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 should just be removed
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.
Looks good to me!
This adds the request tracking available for implementation in CLaSP for Razor.
TODO: