Adds Decorator, wip
This commit is contained in:
parent
a86a2d7ade
commit
49f9b99ee1
9 changed files with 112 additions and 45 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
|
||||
|
|
@ -6,19 +7,24 @@ namespace PlanTempus.Core.Database;
|
|||
|
||||
public class DatabaseScope : IDisposable
|
||||
{
|
||||
private readonly IOperationHolder<DependencyTelemetry> _operation;
|
||||
internal readonly IOperationHolder<DependencyTelemetry> _operation;
|
||||
private readonly Stopwatch _stopwatch;
|
||||
|
||||
public DatabaseScope(IDbConnection connection, IOperationHolder<DependencyTelemetry> operation)
|
||||
{
|
||||
Connection = connection;
|
||||
_operation = operation;
|
||||
_operation.Telemetry.Success = true;
|
||||
_stopwatch = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
public IDbConnection Connection { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_stopwatch.Stop();
|
||||
_operation.Telemetry.Duration = _stopwatch.Elapsed;
|
||||
|
||||
_operation.Dispose();
|
||||
Connection.Dispose();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue