-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Checkpoint * Checkpoint * Checkpoint * checkpoint * Hooking in calls to QueryExecutionService * adding cases * Fleshing out report handlers * Adding parameter converters * Adding sqlparam declarations for Top Resource Consumers and Forced Plans * swapping to object-object to centralize conversion for sqlparams * Adding sqlparams for GetTrackedQueries * Added sqlparams for High Variation * Added Overall ResourceConumption * Adding params for regressed queries * Removing WithWaitStats calls, since they're automatically used within QSM when waitstats is an available statistic# * Adding PlanSummary handlers * cleaning up orderable queries * initial test mockout * adding basic (incorrect) parameter translation * first test passing, datetimeoffset swapped to ISO format * Adding test baselines * Updating nuget package * Adding get/set * Adding get/set for result object * Switching to parameter-less constructor * Swapping TimeInterval for string-based BasicTimeInterval * Removing unnecessary usings * Adding back params comments * Fixing up request docstrings * comment tweak * fix tests failing in pipeline because of line endings not matching * removing unnecessary usings * Setting tests to generate queries in UTC for test stability * Normalizing line endings --------- Co-authored-by: Kim Santiago <[email protected]>
- Loading branch information
Showing
16 changed files
with
2,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+143 KB
bin/nuget/Microsoft.SqlServer.Management.QueryStoreModel.163.26.1.nupkg
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Microsoft.SqlTools.ServiceLayer/QueryStore/BasicTimeInterval.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using Microsoft.SqlServer.Management.QueryStoreModel.Common; | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore | ||
{ | ||
/// <summary> | ||
/// Represents a TimeInterval with strings for the start and end times instead of DateTimeOffsets for JRPC compatibility | ||
/// </summary> | ||
public class BasicTimeInterval | ||
{ | ||
/// <summary> | ||
/// Start time of this time interval, in ISO 8601 format (<code>ToString("O")</code>). | ||
/// This property is ignored unless TimeIntervalOptions is set to Custom. | ||
/// </summary> | ||
public string StartDateTimeInUtc { get; set; } = null; | ||
|
||
/// <summary> | ||
/// End time of this time interval, in ISO 8601 format (<code>ToString("O")</code>). | ||
/// This property is ignored unless TimeIntervalOptions is set to Custom. | ||
/// </summary> | ||
public string EndDateTimeInUtc { get; set; } = null; | ||
|
||
/// <summary> | ||
/// Time interval type. Unless set to Custom, then StartDateTimeInUtc and EndDateTimeInUtc are ignored. | ||
/// </summary> | ||
public TimeIntervalOptions TimeIntervalOptions { get; set; } = TimeIntervalOptions.Custom; | ||
|
||
public TimeInterval Convert() | ||
{ | ||
if (TimeIntervalOptions == TimeIntervalOptions.Custom | ||
&& !String.IsNullOrWhiteSpace(StartDateTimeInUtc) | ||
&& !String.IsNullOrWhiteSpace(EndDateTimeInUtc)) | ||
{ | ||
return new TimeInterval(DateTimeOffset.Parse(StartDateTimeInUtc), DateTimeOffset.Parse(EndDateTimeInUtc)); | ||
} | ||
else if (TimeIntervalOptions != TimeIntervalOptions.Custom | ||
&& String.IsNullOrWhiteSpace(StartDateTimeInUtc) | ||
&& String.IsNullOrWhiteSpace(EndDateTimeInUtc)) | ||
{ | ||
return new TimeInterval(TimeIntervalOptions); | ||
} | ||
else | ||
{ | ||
throw new InvalidOperationException($"{nameof(BasicTimeInterval)} was not populated correctly: '{TimeIntervalOptions}', '{StartDateTimeInUtc}' - '{EndDateTimeInUtc}'"); | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Microsoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetForcedPlanQueriesReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlServer.Management.QueryStoreModel.ForcedPlanQueries; | ||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting a Forced Plan Queries report | ||
/// </summary> | ||
public class GetForcedPlanQueriesReportParams : OrderableQueryConfigurationParams<ForcedPlanQueriesConfiguration> | ||
{ | ||
/// <summary> | ||
/// Time interval for the report | ||
/// </summary> | ||
public BasicTimeInterval TimeInterval { get; set; } | ||
|
||
public override ForcedPlanQueriesConfiguration Convert() | ||
{ | ||
ForcedPlanQueriesConfiguration config = base.Convert(); | ||
config.TimeInterval = TimeInterval.Convert(); | ||
|
||
return config; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a Forced Plan Queries report | ||
/// </summary> | ||
public class GetForcedPlanQueriesReportRequest | ||
{ | ||
public static readonly RequestType<GetForcedPlanQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetForcedPlanQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getForcedPlanQueriesReport"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Microsoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetHighVariationQueriesReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlServer.Management.QueryStoreModel.HighVariation; | ||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting a High Variation Queries report | ||
/// </summary> | ||
public class GetHighVariationQueriesReportParams : OrderableQueryConfigurationParams<HighVariationConfiguration> | ||
{ | ||
/// <summary> | ||
/// Time interval for the report | ||
/// </summary> | ||
public BasicTimeInterval TimeInterval { get; set; } | ||
|
||
public override HighVariationConfiguration Convert() | ||
{ | ||
HighVariationConfiguration config = base.Convert(); | ||
config.TimeInterval = TimeInterval.Convert(); | ||
|
||
return config; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a High Variation Queries report | ||
/// </summary> | ||
public class GetHighVariationQueriesSummaryRequest | ||
{ | ||
public static readonly RequestType<GetHighVariationQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetHighVariationQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getHighVariationQueriesSummary"); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a detailed High Variation Queries report | ||
/// </summary> | ||
public class GetHighVariationQueriesDetailedSummaryRequest | ||
{ | ||
public static readonly RequestType<GetHighVariationQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetHighVariationQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getHighVariationQueriesDetailedSummary"); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...crosoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetOverallResourceConsumptionReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlServer.Management.QueryStoreModel.Common; | ||
using Microsoft.SqlServer.Management.QueryStoreModel.OverallResourceConsumption; | ||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting an Overall Resource Consumption report | ||
/// </summary> | ||
public class GetOverallResourceConsumptionReportParams : QueryConfigurationParams<OverallResourceConsumptionConfiguration> | ||
{ | ||
/// <summary> | ||
/// Time interval for the report | ||
/// </summary> | ||
public BasicTimeInterval SpecifiedTimeInterval { get; set; } | ||
|
||
/// <summary> | ||
/// Bucket interval for the report | ||
/// </summary> | ||
public BucketInterval SpecifiedBucketInterval { get; set; } | ||
|
||
public override OverallResourceConsumptionConfiguration Convert() | ||
{ | ||
OverallResourceConsumptionConfiguration result = base.Convert(); | ||
|
||
result.SpecifiedTimeInterval = SpecifiedTimeInterval.Convert(); | ||
result.SelectedBucketInterval = SpecifiedBucketInterval; | ||
|
||
return result; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for an Overall Resource Consumption report | ||
/// </summary> | ||
public class GetOverallResourceConsumptionReportRequest | ||
{ | ||
public static readonly RequestType<GetOverallResourceConsumptionReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetOverallResourceConsumptionReportParams, QueryStoreQueryResult>.Create("queryStore/getOverallResourceConsumptionReport"); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/Microsoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetRegressedQueriesReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlServer.Management.QueryStoreModel.RegressedQueries; | ||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting a Regressed Queries report | ||
/// </summary> | ||
public class GetRegressedQueriesReportParams : QueryConfigurationParams<RegressedQueriesConfiguration> | ||
{ | ||
/// <summary> | ||
/// Time interval during which to look for performance regressions for the report | ||
/// </summary> | ||
public BasicTimeInterval TimeIntervalRecent { get; set; } | ||
|
||
/// <summary> | ||
/// Time interval during which to establish baseline performance for the report | ||
/// </summary> | ||
public BasicTimeInterval TimeIntervalHistory { get; set; } | ||
|
||
/// <summary> | ||
/// Minimum number of executions for a query to be included | ||
/// </summary> | ||
public long MinExecutionCount { get; set; } | ||
|
||
public override RegressedQueriesConfiguration Convert() | ||
{ | ||
RegressedQueriesConfiguration result = base.Convert(); | ||
|
||
result.TimeIntervalRecent = TimeIntervalRecent.Convert(); | ||
result.TimeIntervalHistory = TimeIntervalHistory.Convert(); | ||
result.MinExecutionCount = MinExecutionCount; | ||
|
||
return result; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a Regressed Queries report | ||
/// </summary> | ||
public class GetRegressedQueriesSummaryRequest | ||
{ | ||
public static readonly RequestType<GetRegressedQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetRegressedQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getRegressedQueriesSummary"); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a detailed Regressed Queries report | ||
/// </summary> | ||
public class GetRegressedQueriesDetailedSummaryRequest | ||
{ | ||
public static readonly RequestType<GetRegressedQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetRegressedQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getRegressedQueriesDetailedSummary"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Microsoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetTopResourceConsumersReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlServer.Management.QueryStoreModel.TopResourceConsumers; | ||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting a Top Resource Consumers report | ||
/// </summary> | ||
public class GetTopResourceConsumersReportParams : OrderableQueryConfigurationParams<TopResourceConsumersConfiguration> | ||
{ | ||
/// <summary> | ||
/// Time interval for the report | ||
/// </summary> | ||
public BasicTimeInterval TimeInterval { get; set; } | ||
|
||
public override TopResourceConsumersConfiguration Convert() | ||
{ | ||
TopResourceConsumersConfiguration result = base.Convert(); | ||
result.TimeInterval = TimeInterval.Convert(); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a Top Resource Consumers report | ||
/// </summary> | ||
public class GetTopResourceConsumersSummaryRequest | ||
{ | ||
public static readonly RequestType<GetTopResourceConsumersReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetTopResourceConsumersReportParams, QueryStoreQueryResult>.Create("queryStore/getTopResourceConsumersSummary"); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a detailed Top Resource Consumers report | ||
/// </summary> | ||
public class GetTopResourceConsumersDetailedSummaryRequest | ||
{ | ||
public static readonly RequestType<GetTopResourceConsumersReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetTopResourceConsumersReportParams, QueryStoreQueryResult>.Create("queryStore/getTopResourceConsumersDetailedSummary"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Microsoft.SqlTools.ServiceLayer/QueryStore/Contracts/GetTrackedQueryReport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.QueryStore.Contracts | ||
{ | ||
/// <summary> | ||
/// Parameters for getting a Tracked Queries report | ||
/// </summary> | ||
public class GetTrackedQueriesReportParams | ||
{ | ||
/// <summary> | ||
/// Search text for a query | ||
/// </summary> | ||
public string QuerySearchText { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Gets the query for a Tracked Queries report | ||
/// </summary> | ||
public class GetTrackedQueriesReportRequest | ||
{ | ||
public static readonly RequestType<GetTrackedQueriesReportParams, QueryStoreQueryResult> Type | ||
= RequestType<GetTrackedQueriesReportParams, QueryStoreQueryResult>.Create("queryStore/getTrackedQueriesReport"); | ||
} | ||
} |
Oops, something went wrong.