-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query : Adds Request Charge to Query Metrics (#4252)
* initial commit * Initial commit * Revert "initial commit" This reverts commit 8393599. * contract updates * support gateway * PR comments * add totalrequestcharge * API update * new trace class * Class cleanup * Move request charge to serversidemetrics - optional * Revert "Move request charge to serversidemetrics - optional" This reverts commit 2999084. * nit fixes
- Loading branch information
1 parent
4d9b7bd
commit 3c18156
Showing
10 changed files
with
120 additions
and
66 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
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
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
70 changes: 70 additions & 0 deletions
70
Microsoft.Azure.Cosmos/src/Query/Core/Metrics/ServerSideMetricsTraceExtractor.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,70 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.Metrics | ||
{ | ||
using System; | ||
using Microsoft.Azure.Cosmos.Tracing; | ||
using Microsoft.Azure.Cosmos.Tracing.TraceData; | ||
|
||
internal static class ServerSideMetricsTraceExtractor | ||
{ | ||
public static void WalkTraceTreeForQueryMetrics(ITrace currentTrace, ServerSideMetricsInternalAccumulator accumulator) | ||
{ | ||
if (currentTrace == null) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (object datum in currentTrace.Data.Values) | ||
{ | ||
if (datum is QueryMetricsTraceDatum queryMetricsTraceDatum) | ||
{ | ||
ServerSideMetricsInternal serverSideMetrics = queryMetricsTraceDatum.QueryMetrics.ServerSideMetrics; | ||
serverSideMetrics.FeedRange = currentTrace.Name; | ||
ServerSideMetricsTraceExtractor.WalkTraceTreeForPartitionInfo(currentTrace, serverSideMetrics); | ||
accumulator.Accumulate(serverSideMetrics); | ||
} | ||
} | ||
|
||
foreach (ITrace childTrace in currentTrace.Children) | ||
{ | ||
ServerSideMetricsTraceExtractor.WalkTraceTreeForQueryMetrics(childTrace, accumulator); | ||
} | ||
} | ||
|
||
private static void WalkTraceTreeForPartitionInfo(ITrace currentTrace, ServerSideMetricsInternal serverSideMetrics) | ||
{ | ||
if (currentTrace == null) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (Object datum in currentTrace.Data.Values) | ||
{ | ||
if (datum is ClientSideRequestStatisticsTraceDatum clientSideRequestStatisticsTraceDatum) | ||
{ | ||
if (clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList.Count > 0) | ||
{ | ||
if (int.TryParse(clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList[0].StoreResult.PartitionKeyRangeId, out int pKRangeId)) | ||
{ | ||
serverSideMetrics.PartitionKeyRangeId = pKRangeId; | ||
} | ||
|
||
serverSideMetrics.RequestCharge = clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList[0].StoreResult.RequestCharge; | ||
} | ||
} | ||
else if (datum is PointOperationStatisticsTraceDatum pointOperationStatisticsTraceDatum) | ||
{ | ||
serverSideMetrics.RequestCharge = pointOperationStatisticsTraceDatum.RequestCharge; | ||
} | ||
} | ||
|
||
foreach (ITrace childTrace in currentTrace.Children) | ||
{ | ||
ServerSideMetricsTraceExtractor.WalkTraceTreeForPartitionInfo(childTrace, serverSideMetrics); | ||
} | ||
} | ||
} | ||
} |
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
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