-
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.
Initial batch of nominal types for DiagnosticSource events
Issue #7938, #8007 * This covers most of the relational events. * Namespace is Microsoft.EntityFrameworkCore.DiagnosticSourceData (Didn't use xxx.xxx.DiagnosticSource as a namespace because then there is a namespace with the same name as a class causing resolution niceness issues.) * Created something of a hierarchy where it made sense so that common code can be used by consumers in some places and to be a bit more DRY. * Tried to be somewhat consistent in ordering, etc. * Made sure ConnectionId and CommandId are exposed where available, specifically including on DataReaderDisposing as requested in #8007.
- Loading branch information
1 parent
e0d3318
commit 302de03
Showing
36 changed files
with
1,490 additions
and
421 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
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
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,85 @@ | ||
// 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.Data.Common; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace Microsoft.EntityFrameworkCore.DiagnosticSourceData | ||
{ | ||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for | ||
/// <see cref="RelationalEventId" /> command events. | ||
/// </summary> | ||
public class CommandData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="command"> | ||
/// The <see cref="DbCommand" />. | ||
/// </param> | ||
/// <param name="executeMethod"> | ||
/// The <see cref="DbCommand" /> method. | ||
/// </param> | ||
/// <param name="commandId"> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </param> | ||
/// <param name="connectionId"> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Indicates whether or not the command was executed asyncronously. | ||
/// </param> | ||
/// <param name="timestamp"> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing. | ||
/// </param> | ||
public CommandData( | ||
[NotNull] DbCommand command, | ||
DbCommandMethod executeMethod, | ||
Guid commandId, | ||
Guid connectionId, | ||
bool async, | ||
long timestamp) | ||
{ | ||
Command = command; | ||
CommandId = commandId; | ||
ConnectionId = connectionId; | ||
ExecuteMethod = executeMethod; | ||
Async = async; | ||
Timestamp = timestamp; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="DbCommand" />. | ||
/// </summary> | ||
public virtual DbCommand Command { get; } | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </summary> | ||
public virtual Guid CommandId { get; } | ||
|
||
/// <summary> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </summary> | ||
public virtual Guid ConnectionId { get; } | ||
|
||
/// <summary> | ||
/// The <see cref="DbCommand" /> method. | ||
/// </summary> | ||
public virtual DbCommandMethod ExecuteMethod { get; } | ||
|
||
/// <summary> | ||
/// Indicates whether or not the operation is being executed asyncronously. | ||
/// </summary> | ||
public virtual bool Async { get; } | ||
|
||
/// <summary> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing. | ||
/// </summary> | ||
public virtual long Timestamp { get; } | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/EFCore.Relational/DiagnosticSourceData/CommandEndData.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,60 @@ | ||
// 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.Data.Common; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace Microsoft.EntityFrameworkCore.DiagnosticSourceData | ||
{ | ||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for | ||
/// <see cref="RelationalEventId" /> command end events. | ||
/// </summary> | ||
public class CommandEndData : CommandData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="command"> | ||
/// The <see cref="DbCommand" />. | ||
/// </param> | ||
/// <param name="executeMethod"> | ||
/// The <see cref="DbCommand" /> method. | ||
/// </param> | ||
/// <param name="commandId"> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </param> | ||
/// <param name="connectionId"> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Indicates whether or not the command was executed asyncronously. | ||
/// </param> | ||
/// <param name="timestamp"> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing. | ||
/// </param> | ||
/// <param name="duration"> | ||
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />. | ||
/// </param> | ||
public CommandEndData( | ||
[NotNull] DbCommand command, | ||
DbCommandMethod executeMethod, | ||
Guid commandId, | ||
Guid connectionId, | ||
bool async, | ||
long timestamp, | ||
long duration) | ||
: base(command, executeMethod, commandId, connectionId, async, timestamp) | ||
{ | ||
Duration = duration; | ||
} | ||
|
||
/// <summary> | ||
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />. | ||
/// </summary> | ||
public virtual long Duration { get; } | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/EFCore.Relational/DiagnosticSourceData/CommandErrorData.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,64 @@ | ||
// 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.Data.Common; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace Microsoft.EntityFrameworkCore.DiagnosticSourceData | ||
{ | ||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.CommandError" />. | ||
/// </summary> | ||
public class CommandErrorData : CommandEndData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="command"> | ||
/// The <see cref="DbCommand" /> that was executing when it failed. | ||
/// </param> | ||
/// <param name="executeMethod"> | ||
/// The <see cref="DbCommand" /> method that was used to execute the command. | ||
/// </param> | ||
/// <param name="commandId"> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </param> | ||
/// <param name="connectionId"> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </param> | ||
/// <param name="exception"> | ||
/// The exception that was thrown when execution failed. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Indicates whether or not the command was executed asyncronously. | ||
/// </param> | ||
/// <param name="timestamp"> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used | ||
/// with <see cref="RelationalEventId.CommandExecuting" /> to time execution. | ||
/// </param> | ||
/// <param name="duration"> | ||
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />. | ||
/// </param> | ||
public CommandErrorData( | ||
[NotNull] DbCommand command, | ||
DbCommandMethod executeMethod, | ||
Guid commandId, | ||
Guid connectionId, | ||
[NotNull] Exception exception, | ||
bool async, | ||
long timestamp, | ||
long duration) | ||
: base(command, executeMethod, commandId, connectionId, async, timestamp, duration) | ||
{ | ||
Exception = exception; | ||
} | ||
|
||
/// <summary> | ||
/// The exception that was thrown when execution failed. | ||
/// </summary> | ||
public virtual Exception Exception { get; } | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/EFCore.Relational/DiagnosticSourceData/CommandExecutedData.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,64 @@ | ||
// 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.Data.Common; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace Microsoft.EntityFrameworkCore.DiagnosticSourceData | ||
{ | ||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.CommandExecuted" />. | ||
/// </summary> | ||
public class CommandExecutedData : CommandEndData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="command"> | ||
/// The <see cref="DbCommand" /> that was executing when it failed. | ||
/// </param> | ||
/// <param name="executeMethod"> | ||
/// The <see cref="DbCommand" /> method that was used to execute the command. | ||
/// </param> | ||
/// <param name="commandId"> | ||
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used. | ||
/// </param> | ||
/// <param name="connectionId"> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </param> | ||
/// <param name="result"> | ||
/// The result of executing the operation. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Indicates whether or not the command was executed asyncronously. | ||
/// </param> | ||
/// <param name="timestamp"> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used | ||
/// with <see cref="RelationalEventId.CommandExecuting" /> to time execution. | ||
/// </param> | ||
/// <param name="duration"> | ||
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />. | ||
/// </param> | ||
public CommandExecutedData( | ||
[NotNull] DbCommand command, | ||
DbCommandMethod executeMethod, | ||
Guid commandId, | ||
Guid connectionId, | ||
[CanBeNull] object result, | ||
bool async, | ||
long timestamp, | ||
long duration) | ||
: base(command, executeMethod, commandId, connectionId, async, timestamp, duration) | ||
{ | ||
Result = result; | ||
} | ||
|
||
/// <summary> | ||
/// The result of executing the command. | ||
/// </summary> | ||
public virtual object Result { get; } | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/EFCore.Relational/DiagnosticSourceData/ConnectionData.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,65 @@ | ||
// 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.Data.Common; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
|
||
namespace Microsoft.EntityFrameworkCore.DiagnosticSourceData | ||
{ | ||
/// <summary> | ||
/// The <see cref="DiagnosticSource" /> event payload base class for | ||
/// <see cref="RelationalEventId" /> connection events. | ||
/// </summary> | ||
public class ConnectionData | ||
{ | ||
/// <summary> | ||
/// Constructs the event payload. | ||
/// </summary> | ||
/// <param name="connection"> | ||
/// The <see cref="DbConnection" />. | ||
/// </param> | ||
/// <param name="connectionId"> | ||
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Indicates whether or not the operation is happening asyncronously. | ||
/// </param> | ||
/// <param name="timestamp"> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing. | ||
/// </param> | ||
public ConnectionData( | ||
[NotNull] DbConnection connection, | ||
Guid connectionId, | ||
bool async, | ||
long timestamp) | ||
{ | ||
Connection = connection; | ||
ConnectionId = connectionId; | ||
Async = async; | ||
Timestamp = timestamp; | ||
} | ||
|
||
/// <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> | ||
/// Indicates whether or not the operation is happening asyncronously. | ||
/// </summary> | ||
public virtual bool Async { get; } | ||
|
||
/// <summary> | ||
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing. | ||
/// </summary> | ||
public virtual long Timestamp { get; } | ||
} | ||
} |
Oops, something went wrong.