-
Notifications
You must be signed in to change notification settings - Fork 495
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
Diagnostic Visitors #1156
Diagnostic Visitors #1156
Conversation
Microsoft.Azure.Cosmos/src/Diagnostics/CosmosDiagnosticsSerializerVisitor.cs
Outdated
Show resolved
Hide resolved
@@ -123,6 +124,36 @@ sealed class BackendMetrics | |||
/// </summary> | |||
public TimeSpan VMExecutionTime { get; } | |||
|
|||
public override string ToString() | |||
{ | |||
return $"totalExecutionTimeInMs={this.TotalTime.TotalMilliseconds};" + |
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.
Use StringBuilder this is going to cause to much perf overhead. #Resolved
} | ||
|
||
internal void AddContextWriter(CosmosDiagnosticWriter diagnosticWriter) | ||
internal void AddContextWriter(CosmosDiagnosticsInternal diagnosticWriter) |
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.
AddDiagnosticsInternal ? #Resolved
Microsoft.Azure.Cosmos/src/Diagnostics/CosmosDiagnosticsSerializerVisitor.cs
Show resolved
Hide resolved
this.jsonWriter = new JsonTextWriter(textWriter ?? throw new ArgumentNullException(nameof(textWriter))); | ||
} | ||
|
||
public override void Visit(PointOperationStatistics pointOperationStatistics) |
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.
Did this make any changes to the output string? If so can you provide an example in the description. #Resolved
Microsoft.Azure.Cosmos/src/Diagnostics/CosmosDiagnosticsInternalVisitor.cs
Show resolved
Hide resolved
/// <summary> | ||
/// Extracts the aggregated <see cref="BackendMetrics"/> from a <see cref="CosmosDiagnostics"/>. | ||
/// </summary> | ||
internal sealed class BackendMetricsExtractor : CosmosDiagnosticsInternalVisitor<(bool, BackendMetrics)> |
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.
(bool, BackendMetrics [](start = 85, length = 21)
Nullable #Resolved
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.
/// <summary> | ||
/// Extracts the aggregated <see cref="BackendMetrics"/> from a <see cref="CosmosDiagnostics"/>. | ||
/// </summary> | ||
internal sealed class BackendMetricsExtractor : CosmosDiagnosticsInternalVisitor<(bool, BackendMetrics)> |
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.
bool [](start = 86, length = 4)
enum for the failure reason #Resolved
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.
if (!this.isDisposed) | ||
{ | ||
return false; | ||
} |
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 we should not have a TryGet method here; rather, we should return whatever value the stopwatch has #Resolved
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's better to have a TryGet. It's misleading if it returns the current elapsed time if the operation was never disposed of or still hasn't completed if there is a background task then it causes it to be ambiguous. #Resolved
{ | ||
CosmosDiagnosticsSerializerVisitor cosmosDiagnosticsSerializerVisitor = new CosmosDiagnosticsSerializerVisitor(textWriter); | ||
this.Accept(cosmosDiagnosticsSerializerVisitor); | ||
} |
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.
consider moving this to the base class #Resolved
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.
The base class doesn't have the visitor methods that are needed for this
In reply to: 369911329 [](ancestors = 369911329)
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.
@@ -12,6 +12,7 @@ namespace Microsoft.Azure.Cosmos.Tests | |||
using System.Net.Http; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using Microsoft.Azure.Cosmos.Diagnostics; |
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.
undo?
Similar places #Resolved
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.
The namespace was changed intentionally to match the file structure
In reply to: 369949865 [](ancestors = 369949865)
Diagnostic Visitors
Description
This PR adds visitor to CosmosDiagnostics. This ensures that for the abstract type CosmosDiagnostics the compute gateway can handle every derived type (or else there will be a compile time error). BackendMetricsExtractor is an example of this. This essentially turns a soft contract into a hard contract. I added
CosmosDiagnosticsInternal
to extend CosmosDiagnostics, but for internal use only.