-
Notifications
You must be signed in to change notification settings - Fork 491
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
Draft: 3892: Adding metrics to Azure Benchmark tool #3897
Closed
M-Lipin
wants to merge
10
commits into
Azure:master
from
M-Lipin:users/v-milipin/benchmark-metrics-3892
Closed
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9bd7ba8
Adding metrics to Azure Benchmark tool.
M-Lipin b34ba6e
Adding 999 and 9999 quantiles.
M-Lipin 36308e6
Base classes for operations.
M-Lipin f450f54
Separating operations and metrics collecting, refactoring, code clean…
M-Lipin f644c20
Tracking percentiles with AppInsights TelemetryClient.
92adc38
Moving back to OpenTelemetry.
270aece
Adding gauges.
33a2597
Adding configurable flush interval.
7888b8e
Adding ARM template for Dashboard.
c55f4c2
Adding Application Insights resource.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 16 additions & 0 deletions
16
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfigProvider.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,16 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics; | ||
using App.Metrics.Counter; | ||
using App.Metrics.Timer; | ||
|
||
// TODO: Temporary solution. Remove after adding DI. | ||
public class BenchmarkConfigProvider | ||
{ | ||
public static BenchmarkConfig CurrentBenchmarkConfig { get; set; } | ||
} | ||
} |
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 |
---|---|---|
|
@@ -17,9 +17,17 @@ | |
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="App.Metrics" Version="4.3.0" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why App.Metrics and not System.Diagnostics.Metrics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please set-up a design review. |
||
<PackageReference Include="App.Metrics.Abstractions" Version="4.3.0" /> | ||
<PackageReference Include="App.Metrics.Reporting.ApplicationInsights" Version="3.0.0" /> | ||
<PackageReference Include="App.Metrics.Reporting.Console" Version="4.3.0" /> | ||
<PackageReference Include="CommandLineParser" Version="2.8.0" /> | ||
<PackageReference Include="MathNet.Numerics" Version="4.15.0" /> | ||
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" /> | ||
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="*" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(ProjectRef)' != 'True' "> | ||
|
15 changes: 15 additions & 0 deletions
15
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/BenchmarkOperation.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,15 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using System.Threading.Tasks; | ||
|
||
internal abstract class BenchmarkOperation : IBenchmarkOperation | ||
{ | ||
public abstract Task<OperationResult> ExecuteOnceAsync(); | ||
|
||
public abstract Task PrepareAsync(); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/IMetricsCollector.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,17 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics.Timer; | ||
|
||
public interface IMetricsCollector | ||
{ | ||
TimerContext GetTimer(); | ||
|
||
void CollectMetricsOnSuccess(); | ||
|
||
void CollectMetricsOnFailure(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/InsertBenchmarkOperation.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,13 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics; | ||
using App.Metrics.Timer; | ||
|
||
internal abstract class InsertBenchmarkOperation : BenchmarkOperation | ||
{ | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/InsertOperationMetricsCollector.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 Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics.Timer; | ||
using App.Metrics; | ||
|
||
internal class InsertOperationMetricsCollector : MetricsCollector | ||
{ | ||
public InsertOperationMetricsCollector(MetricsContext metricsContext, IMetrics metrics) : base(metricsContext, metrics) | ||
{ | ||
} | ||
|
||
public override TimerContext GetTimer() | ||
{ | ||
return this.metrics.Measure.Timer.Time(this.metricsContext.InsertLatencyTimer); | ||
} | ||
|
||
public override void CollectMetricsOnSuccess() | ||
{ | ||
this.metrics.Measure.Counter.Increment(this.metricsContext.WriteSuccessMeter); | ||
} | ||
|
||
public override void CollectMetricsOnFailure() | ||
{ | ||
this.metrics.Measure.Counter.Increment(this.metricsContext.WriteFailureMeter); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/MetricsCollector.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,28 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics.Timer; | ||
using App.Metrics; | ||
|
||
internal abstract class MetricsCollector : IMetricsCollector | ||
{ | ||
protected MetricsContext metricsContext; | ||
|
||
protected IMetrics metrics; | ||
|
||
public MetricsCollector(MetricsContext metricsContext, IMetrics metrics) | ||
{ | ||
this.metricsContext = metricsContext; | ||
this.metrics = metrics; | ||
} | ||
|
||
public abstract TimerContext GetTimer(); | ||
|
||
public abstract void CollectMetricsOnFailure(); | ||
|
||
public abstract void CollectMetricsOnSuccess(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/MetricsCollectorProvider.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,33 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using System; | ||
using App.Metrics; | ||
|
||
internal static class MetricsCollectorProvider | ||
{ | ||
public static IMetricsCollector GetMetricsCollector(IBenchmarkOperation benchmarkOperation, MetricsContext metricsContext, IMetrics metrics) | ||
{ | ||
Type benchmarkOperationType = benchmarkOperation.GetType(); | ||
if (typeof(InsertBenchmarkOperation).IsAssignableFrom(benchmarkOperationType)) | ||
{ | ||
return new InsertOperationMetricsCollector(metricsContext, metrics); | ||
} | ||
else if (typeof(QueryBenchmarkOperation).IsAssignableFrom(benchmarkOperationType)) | ||
{ | ||
return new QueryOperationMetricsCollector(metricsContext, metrics); | ||
} | ||
else if (typeof(ReadBenchmarkOperation).IsAssignableFrom(benchmarkOperationType)) | ||
{ | ||
return new ReadOperationMetricsCollector(metricsContext, metrics); | ||
} | ||
else | ||
{ | ||
throw new NotSupportedException($"The type {nameof(benchmarkOperationType)} is not supported for collecting metrics."); | ||
} | ||
} | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/QueryBenchmarkOperation.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,10 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
internal abstract class QueryBenchmarkOperation : BenchmarkOperation | ||
{ | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/QueryOperationMetricsCollector.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 Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using App.Metrics; | ||
using App.Metrics.Timer; | ||
|
||
internal class QueryOperationMetricsCollector : MetricsCollector | ||
{ | ||
public QueryOperationMetricsCollector(MetricsContext metricsContext, IMetrics metrics) : base(metricsContext, metrics) | ||
{ | ||
} | ||
|
||
public override TimerContext GetTimer() | ||
{ | ||
return this.metrics.Measure.Timer.Time(this.metricsContext.QueryLatencyTimer); | ||
} | ||
|
||
public override void CollectMetricsOnSuccess() | ||
{ | ||
this.metrics.Measure.Counter.Increment(this.metricsContext.QuerySuccessMeter); | ||
} | ||
|
||
public override void CollectMetricsOnFailure() | ||
{ | ||
this.metrics.Measure.Counter.Increment(this.metricsContext.QueryFailureMeter); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/Fx/ReadBenchmarkOperation.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,10 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
internal abstract class ReadBenchmarkOperation : BenchmarkOperation | ||
{ | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
NOTE: Required.