-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use loggging infrastructure on Cosmos (#23517)
Fixes #19063
- Loading branch information
1 parent
42cdfb8
commit 691eaac
Showing
14 changed files
with
501 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for Cosmos query events. | ||
/// </summary> | ||
public class CosmosQueryEventData : 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="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 or not the application allows logging of sensitive data. </param> | ||
public CosmosQueryEventData( | ||
[NotNull] EventDefinitionBase eventDefinition, | ||
[NotNull] Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
[NotNull] string containerId, | ||
[CanBeNull] string partitionKey, | ||
[NotNull] IReadOnlyList<(string Name, object Value)> parameters, | ||
[NotNull] string querySql, | ||
bool logSensitiveData) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
ContainerId = containerId; | ||
PartitionKey = partitionKey; | ||
Parameters = parameters; | ||
QuerySql = querySql; | ||
LogSensitiveData = logSensitiveData; | ||
} | ||
|
||
/// <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 or not 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A <see cref="DiagnosticSource" /> event payload class for Cosmos read-item events. | ||
/// </summary> | ||
public class CosmosReadItemEventData : 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="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 or not the application allows logging of sensitive data. </param> | ||
public CosmosReadItemEventData( | ||
[NotNull] EventDefinitionBase eventDefinition, | ||
[NotNull] Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
[NotNull] string resourceId, | ||
[NotNull] string containerId, | ||
[CanBeNull] string partitionKey, | ||
bool logSensitiveData) | ||
: base(eventDefinition, messageGenerator) | ||
{ | ||
ResourceId = resourceId; | ||
ContainerId = containerId; | ||
PartitionKey = partitionKey; | ||
LogSensitiveData = logSensitiveData; | ||
} | ||
|
||
/// <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 or not 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
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.