Example #1
0
 public virtual void ConnectionClosed(
     DbConnection connection,
     ConnectionEndEventData eventData)
 {
     Assert.False(eventData.IsAsync);
     SyncCalled = true;
     AssertClosed(eventData);
 }
 public void ConnectionOpened(
     DbConnection connection,
     ConnectionEndEventData eventData)
 {
     for (var i = 0; i < _interceptors.Length; i++)
     {
         _interceptors[i].ConnectionOpened(connection, eventData);
     }
 }
 public async Task ConnectionClosedAsync(
     DbConnection connection,
     ConnectionEndEventData eventData)
 {
     for (var i = 0; i < _interceptors.Length; i++)
     {
         await _interceptors[i].ConnectionClosedAsync(connection, eventData);
     }
 }
Example #4
0
        public override Task ConnectionOpenedAsync(
            DbConnection connection,
            ConnectionEndEventData eventData,
            CancellationToken cancellationToken = default)
        {
            this.RegisterCustomTypeMappers((NpgsqlConnection)connection);

            return(Task.CompletedTask);
        }
Example #5
0
            public virtual Task ConnectionClosedAsync(
                DbConnection connection,
                ConnectionEndEventData eventData)
            {
                Assert.True(eventData.IsAsync);
                AsyncCalled = true;
                AssertClosed(eventData);

                return(Task.CompletedTask);
            }
 public async Task ConnectionOpenedAsync(
     DbConnection connection,
     ConnectionEndEventData eventData,
     CancellationToken cancellationToken = default)
 {
     for (var i = 0; i < _interceptors.Length; i++)
     {
         await _interceptors[i].ConnectionOpenedAsync(connection, eventData, cancellationToken);
     }
 }
Example #7
0
            public virtual Task ConnectionOpenedAsync(
                DbConnection connection,
                ConnectionEndEventData eventData,
                CancellationToken cancellationToken = default)
            {
                Assert.True(eventData.IsAsync);
                AsyncCalled = true;
                AssertOpened(eventData);

                return(Task.CompletedTask);
            }
Example #8
0
        private void HandleConnection(string name, ConnectionEndEventData eventData)
        {
            ConnectionMetric metric;

            if (name == RelationalEventId.ConnectionOpened.Name)
            {
                metric = new ConnectionMetric(eventData)
                {
                    Action          = "Open",
                    ConnectionDelta = 1,
                    Duration        = eventData.Duration
                };

                _connectionNames.TryAdd(eventData.ConnectionId, metric.InstanceName);
            }
            else if (name == RelationalEventId.ConnectionClosed.Name)
            {
                // *sigh*.  We've found the server names don't always match between open and close
                //so look up our cached value..
                if (_connectionNames.TryRemove(eventData.ConnectionId, out string instanceName))
                {
                    metric = new ConnectionMetric(eventData, instanceName)
                    {
                        Action          = "Closed",
                        ConnectionDelta = -1,
                        Duration        = eventData.Duration
                    };
                }
                else
                {
                    // we ignore the else clause because it's not a "matching" event.
                    return;
                }
            }
            else
            {
                return;
            }

            EventMetric.Write(metric);
            SampledMetric.Write(metric);
        }
 /// <summary>
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="eventData"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public override Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = default)
 {
     return(base.ConnectionOpenedAsync(connection, eventData, cancellationToken));
 }
Example #10
0
 public override void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)
 {
     Assert.Equal(_goodConnectionString, eventData.Context.Database.GetConnectionString());
     eventData.Context.Database.SetConnectionString(_dummyConnectionString);
 }
Example #11
0
 public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
 {
     this.RegisterCustomTypeMappers((NpgsqlConnection)connection);
 }
Example #12
0
 public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
 {
     base.ConnectionOpened(connection, eventData);
 }
Example #13
0
 public override async Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)
 {
     await base.ConnectionClosedAsync(connection, eventData);
 }
 /// <summary>
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="eventData"></param>
 /// <returns></returns>
 public override Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)
 {
     return(base.ConnectionClosedAsync(connection, eventData));
 }
 public Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)
 {
     TrackEvent(nameof(ConnectionClosedAsync), connection, eventData.ConnectionId);
     RemoveOperationHolder(eventData.ConnectionId);
     return(Task.CompletedTask);
 }
 public void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)
 {
     TrackEvent(nameof(ConnectionClosed), connection, eventData.ConnectionId);
     RemoveOperationHolder(eventData.ConnectionId);
 }
 public Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData,
                                   CancellationToken cancellationToken = new CancellationToken())
 {
     TrackEvent(nameof(ConnectionOpenedAsync), connection, eventData.ConnectionId);
     return(Task.CompletedTask);
 }
 public void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
 {
     TrackEvent(nameof(ConnectionOpened), connection, eventData.ConnectionId);
 }
Example #19
0
 public override async Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = new CancellationToken())
 {
     await base.ConnectionOpenedAsync(connection, eventData, cancellationToken);
 }
Example #20
0
 public override void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)
 {
 }