mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-01 17:24:42 -05:00
Formatter and PeekDefinition Telemetry (#245)
- Add telemetry point for format requests - Update PeekDefinition telemetry so that it captures whether the attempt succeeded and if it was connected. This will help us understand whether our current behavior of just notifying success/failure to the output window was useful or not. It will also help us understand whether we're doing a good job implementing this / if we need to improve reliability and preformance.
This commit is contained in:
@@ -13,6 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.Extensibility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Formatter.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
@@ -40,9 +41,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
{
|
||||
serviceHost.SetRequestHandler(DocumentFormattingRequest.Type, HandleDocFormatRequest);
|
||||
serviceHost.SetRequestHandler(DocumentRangeFormattingRequest.Type, HandleDocRangeFormatRequest);
|
||||
|
||||
|
||||
|
||||
WorkspaceService?.RegisterConfigChangeCallback(HandleDidChangeConfigurationNotification);
|
||||
}
|
||||
|
||||
@@ -75,6 +73,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
return FormatAndReturnEdits(docFormatParams);
|
||||
};
|
||||
await HandleRequest(requestHandler, requestContext, "HandleDocFormatRequest");
|
||||
|
||||
DocumentStatusHelper.SendTelemetryEvent(requestContext, CreateTelemetryProps(isDocFormat: true));
|
||||
}
|
||||
|
||||
public async Task HandleDocRangeFormatRequest(DocumentRangeFormattingParams docRangeFormatParams, RequestContext<TextEdit[]> requestContext)
|
||||
@@ -84,6 +84,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
return FormatRangeAndReturnEdits(docRangeFormatParams);
|
||||
};
|
||||
await HandleRequest(requestHandler, requestContext, "HandleDocRangeFormatRequest");
|
||||
|
||||
DocumentStatusHelper.SendTelemetryEvent(requestContext, CreateTelemetryProps(isDocFormat: false));
|
||||
}
|
||||
private static TelemetryProperties CreateTelemetryProps(bool isDocFormat)
|
||||
{
|
||||
return new TelemetryProperties
|
||||
{
|
||||
Properties = new Dictionary<string, string>
|
||||
{
|
||||
{ TelemetryPropertyNames.FormatType,
|
||||
isDocFormat ? TelemetryPropertyNames.DocumentFormatType : TelemetryPropertyNames.RangeFormatType }
|
||||
},
|
||||
EventName = TelemetryEventNames.FormatCode
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<TextEdit[]> FormatRangeAndReturnEdits(DocumentRangeFormattingParams docFormatParams)
|
||||
@@ -141,7 +155,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
}
|
||||
UpdateFormatOptionsFromSettings(options, settings);
|
||||
return options;
|
||||
|
||||
}
|
||||
|
||||
internal static void UpdateFormatOptionsFromSettings(FormatOptions options, FormatterSettings settings)
|
||||
|
||||
Reference in New Issue
Block a user