-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cosmos: Add diagnostic events with statistics
Fixes #17298
- Loading branch information
1 parent
15167f6
commit c74f3c1
Showing
12 changed files
with
910 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
81 changes: 81 additions & 0 deletions
81
src/EFCore.Cosmos/Diagnostics/CosmosItemCommandExecutedEventData.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,81 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for Cosmos item command executed events. | ||
/// </summary> | ||
public class CosmosItemCommandExecutedEventData : EventData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition"> The event definition. </param> | ||
/// <param name="messageGenerator"> A delegate that generates a log message for this event. </param> | ||
/// <param name="elapsed"> The time elapsed since the command was sent to the database. </param> | ||
/// <param name="requestCharge"> The request charge in RU. </param> | ||
/// <param name="activityId"> The activity ID. </param> | ||
/// <param name="resourceId"> The ID of the resource being read. </param> | ||
/// <param name="containerId"> The ID of the Cosmos container being queried. </param> | ||
/// <param name="partitionKey"> The key of the Cosmos partition that the query is using. </param> | ||
/// <param name="logSensitiveData"> Indicates whether the application allows logging of sensitive data. </param> | ||
public CosmosItemCommandExecutedEventData( | ||
EventDefinitionBase eventDefinition, | ||
Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
TimeSpan elapsed, | ||
double requestCharge, | ||
string activityId, | ||
string containerId, | ||
string resourceId, | ||
string? partitionKey, | ||
bool logSensitiveData) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
Elapsed = elapsed; | ||
RequestCharge = requestCharge; | ||
ActivityId = activityId; | ||
ContainerId = containerId; | ||
ResourceId = resourceId; | ||
PartitionKey = partitionKey; | ||
LogSensitiveData = logSensitiveData; | ||
} | ||
|
||
/// <summary> | ||
/// The time elapsed since the command was sent to the database. | ||
/// </summary> | ||
public TimeSpan Elapsed { get; } | ||
|
||
/// <summary> | ||
/// The request charge in RU. | ||
/// </summary> | ||
public double RequestCharge { get; } | ||
|
||
/// <summary> | ||
/// The activity ID. | ||
/// </summary> | ||
public string ActivityId { get; } | ||
|
||
/// <summary> | ||
/// The ID of the Cosmos container being queried. | ||
/// </summary> | ||
public virtual string ContainerId { get; } | ||
|
||
/// <summary> | ||
/// The ID of the resource being read. | ||
/// </summary> | ||
public virtual string ResourceId { get; } | ||
|
||
/// <summary> | ||
/// The key of the Cosmos partition that the query is using. | ||
/// </summary> | ||
public virtual string? PartitionKey { get; } | ||
|
||
/// <summary> | ||
/// Indicates whether the application allows logging of sensitive data. | ||
/// </summary> | ||
public virtual bool LogSensitiveData { get; } | ||
} | ||
} |
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
89 changes: 89 additions & 0 deletions
89
src/EFCore.Cosmos/Diagnostics/CosmosQueryExecutedEventData.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,89 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for Cosmos query events. | ||
/// </summary> | ||
public class CosmosQueryExecutedEventData : EventData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="eventDefinition"> The event definition. </param> | ||
/// <param name="messageGenerator"> A delegate that generates a log message for this event. </param> | ||
/// <param name="elapsed"> The time elapsed since the command was sent to the database. </param> | ||
/// <param name="requestCharge"> The request charge in RU. </param> | ||
/// <param name="activityId"> The activity ID. </param> | ||
/// <param name="containerId"> The ID of the Cosmos container being queried. </param> | ||
/// <param name="partitionKey"> The key of the Cosmos partition that the query is using. </param> | ||
/// <param name="parameters"> Name/values for each parameter in the Cosmos Query. </param> | ||
/// <param name="querySql"> The SQL representing the query. </param> | ||
/// <param name="logSensitiveData"> Indicates whether the application allows logging of sensitive data. </param> | ||
public CosmosQueryExecutedEventData( | ||
EventDefinitionBase eventDefinition, | ||
Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
TimeSpan elapsed, | ||
double requestCharge, | ||
string activityId, | ||
string containerId, | ||
string? partitionKey, | ||
IReadOnlyList<(string Name, object? Value)> parameters, | ||
string querySql, | ||
bool logSensitiveData) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
Elapsed = elapsed; | ||
RequestCharge = requestCharge; | ||
ActivityId = activityId; | ||
ContainerId = containerId; | ||
PartitionKey = partitionKey; | ||
Parameters = parameters; | ||
QuerySql = querySql; | ||
LogSensitiveData = logSensitiveData; | ||
} | ||
|
||
/// <summary> | ||
/// The time elapsed since the command was sent to the database. | ||
/// </summary> | ||
public virtual TimeSpan Elapsed { get; } | ||
|
||
/// <summary> | ||
/// The request charge in RU. | ||
/// </summary> | ||
public virtual double RequestCharge { get; } | ||
|
||
/// <summary> | ||
/// The activity ID. | ||
/// </summary> | ||
public virtual string ActivityId { get; } | ||
|
||
/// <summary> | ||
/// The ID of the Cosmos container being queried. | ||
/// </summary> | ||
public virtual string ContainerId { get; } | ||
|
||
/// <summary> | ||
/// The key of the Cosmos partition that the query is using. | ||
/// </summary> | ||
public virtual string? PartitionKey { get; } | ||
|
||
/// <summary> | ||
/// Name/values for each parameter in the Cosmos Query. | ||
/// </summary> | ||
public virtual IReadOnlyList<(string Name, object? Value)> Parameters { get; } | ||
|
||
/// <summary> | ||
/// The SQL representing the query. | ||
/// </summary> | ||
public virtual string QuerySql { get; } | ||
|
||
/// <summary> | ||
/// Indicates whether the application allows logging of sensitive data. | ||
/// </summary> | ||
public virtual bool LogSensitiveData { get; } | ||
} | ||
} |
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
Oops, something went wrong.