@@ -36,8 +36,9 @@ public class AmqpConnection : AbstractLifeCycle, IConnection
3636 private readonly RecordingTopologyListener _recordingTopologyListener = new ( ) ;
3737
3838 internal readonly IConnectionSettings _connectionSettings ;
39+ private readonly IMetricsReporter _metricsReporter ;
3940 internal readonly AmqpSessionManagement _nativePubSubSessions ;
40-
41+
4142 /// <summary>
4243 /// Publishers contains all the publishers created by the connection.
4344 /// Each connection can have multiple publishers.
@@ -93,10 +94,9 @@ public ReadOnlyCollection<IConsumer> GetConsumers()
9394 /// <param name="metricsReporter"></param>
9495 /// <returns></returns>
9596 public static async Task < IConnection > CreateAsync ( IConnectionSettings connectionSettings ,
96- IMetricsReporter ? metricsReporter = null )
97+ IMetricsReporter ? metricsReporter = default )
9798 {
98- metricsReporter ??= new NoOpMetricsReporter ( ) ;
99- var connection = new AmqpConnection ( connectionSettings ) ;
99+ var connection = new AmqpConnection ( connectionSettings , metricsReporter ?? new NoOpMetricsReporter ( ) ) ;
100100 await connection . OpenAsync ( )
101101 . ConfigureAwait ( false ) ;
102102 return connection ;
@@ -109,7 +109,7 @@ public IManagement Management()
109109
110110 public IConsumerBuilder ConsumerBuilder ( )
111111 {
112- return new AmqpConsumerBuilder ( this ) ;
112+ return new AmqpConsumerBuilder ( this , _metricsReporter ) ;
113113 }
114114
115115 // TODO cancellation token
@@ -125,7 +125,7 @@ await base.OpenAsync()
125125 public IPublisherBuilder PublisherBuilder ( )
126126 {
127127 ThrowIfClosed ( ) ;
128- var publisherBuilder = new AmqpPublisherBuilder ( this ) ;
128+ var publisherBuilder = new AmqpPublisherBuilder ( this , _metricsReporter ) ;
129129 return publisherBuilder ;
130130 }
131131
@@ -221,9 +221,10 @@ await consumer.CloseAsync()
221221 }
222222 }
223223
224- private AmqpConnection ( IConnectionSettings connectionSettings )
224+ private AmqpConnection ( IConnectionSettings connectionSettings , IMetricsReporter metricsReporter )
225225 {
226226 _connectionSettings = connectionSettings ;
227+ _metricsReporter = metricsReporter ;
227228 _nativePubSubSessions = new AmqpSessionManagement ( this , 1 ) ;
228229 _management =
229230 new AmqpManagement ( new AmqpManagementParameters ( this ) . TopologyListener ( _recordingTopologyListener ) ) ;
0 commit comments