-
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.
Add creation and disposal to connection interception (#27920)
Co-authored-by: Andriy Svyryd <[email protected]>
- Loading branch information
1 parent
8d80ea9
commit 7ad294c
Showing
18 changed files
with
1,550 additions
and
73 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/EFCore.Relational/Diagnostics/ConnectionCreatedEventData.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,59 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics; | ||
|
||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.ConnectionCreated"/> events. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-diagnostics">Logging, events, and diagnostics</see> for more information and examples. | ||
/// </remarks> | ||
public class ConnectionCreatedEventData : DbContextEventData | ||
{ | ||
/// <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="connection">The <see cref="DbConnection" />.</param> | ||
/// <param name="context">The <see cref="DbContext" /> currently being used, to null if not known.</param> | ||
/// <param name="connectionId">A correlation ID that identifies the <see cref="DbConnection" /> instance being used.</param> | ||
/// <param name="startTime">The start time of this event.</param> | ||
/// <param name="duration">The duration this event.</param> | ||
public ConnectionCreatedEventData( | ||
EventDefinitionBase eventDefinition, | ||
Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
DbConnection connection, | ||
DbContext? context, | ||
Guid connectionId, | ||
DateTimeOffset startTime, | ||
TimeSpan duration) | ||
: base(eventDefinition, messageGenerator, context) | ||
{ | ||
Connection = connection; | ||
ConnectionId = connectionId; | ||
StartTime = startTime; | ||
Duration = duration; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="DbConnection" />. | ||
/// </summary> | ||
public virtual DbConnection Connection { get; } | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </summary> | ||
public virtual Guid ConnectionId { get; } | ||
|
||
/// <summary> | ||
/// The start time of this event. | ||
/// </summary> | ||
public virtual DateTimeOffset StartTime { get; } | ||
|
||
/// <summary> | ||
/// The duration of this event. | ||
/// </summary> | ||
public virtual TimeSpan Duration { get; } | ||
} |
43 changes: 43 additions & 0 deletions
43
src/EFCore.Relational/Diagnostics/ConnectionCreatingEventData.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,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Diagnostics; | ||
|
||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.ConnectionCreating"/> events. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-diagnostics">Logging, events, and diagnostics</see> for more information and examples. | ||
/// </remarks> | ||
public class ConnectionCreatingEventData : DbContextEventData | ||
{ | ||
/// <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="context">The <see cref="DbContext" /> currently being used, to null if not known.</param> | ||
/// <param name="connectionId">A correlation ID that identifies the <see cref="DbConnection" /> instance being used.</param> | ||
/// <param name="startTime">The start time of this event.</param> | ||
public ConnectionCreatingEventData( | ||
EventDefinitionBase eventDefinition, | ||
Func<EventDefinitionBase, EventData, string> messageGenerator, | ||
DbContext? context, | ||
Guid connectionId, | ||
DateTimeOffset startTime) | ||
: base(eventDefinition, messageGenerator, context) | ||
{ | ||
ConnectionId = connectionId; | ||
StartTime = startTime; | ||
} | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </summary> | ||
public virtual Guid ConnectionId { get; } | ||
|
||
/// <summary> | ||
/// The start time of this event. | ||
/// </summary> | ||
public virtual DateTimeOffset StartTime { 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.