public sealed class SqlClientObserver : IObserver<DiagnosticListener>, IObserver<KeyValuePair<string, object>>
{
    private readonly IList<IDisposable> _listeners = new List<IDisposable>();
    
    void IObserver<DiagnosticListener>.OnNext(DiagnosticListener diagnosticListener)
    {
       lock (_listeners)
       {
          if (diagnosticListener.Name == "SqlClientDiagnosticListener")
          {
              var subscription = diagnosticListener.Subscribe(this);
              _listeners.Add(subscription);
          }
       }
    }
    
    void IObserver<DiagnosticListener>.OnError(Exception error)
    { }
    
    void IObserver<DiagnosticListener>.OnCompleted()
    {
      lock(_listeners)
      {
          _listeners.ForEach(x => x.Dispose());
          _listeners.Clear();
      }
    }

    void IObserver<KeyValuePair<string, object>>.OnNext(KeyValuePair<string, object> pair)
    {
        Console.WriteLine(pair.Key);
        Console.WriteLine(pair.Value)
    }
    
    void IObserver<KeyValuePair<string, object>>.OnError(Exception error)
    { }
    
    void IObserver<KeyValuePair<string, object>>.OnCompleted()
    { }
}