@@ -63,7 +63,6 @@ public static class RabbitMQActivitySource
6363 DefaultContextExtractor ;
6464
6565 public static bool UseRoutingKeyAsOperationName { get ; set ; } = true ;
66- internal static bool PublisherHasListeners => s_publisherSource . HasListeners ( ) ;
6766
6867 internal static readonly IEnumerable < KeyValuePair < string , object ? > > CreationTags = new [ ]
6968 {
@@ -74,11 +73,6 @@ public static class RabbitMQActivitySource
7473
7574 internal static Activity ? OpenConnection ( IFrameHandler frameHandler )
7675 {
77- if ( ! s_connectionSource . HasListeners ( ) )
78- {
79- return null ;
80- }
81-
8276 Activity ? connectionActivity =
8377 s_connectionSource . StartRabbitMQActivity ( "connection attempt" , ActivityKind . Client ) ;
8478 connectionActivity ?
@@ -89,11 +83,6 @@ public static class RabbitMQActivitySource
8983 internal static Activity ? BasicPublish ( string routingKey , string exchange , int bodySize ,
9084 ActivityContext linkedContext = default )
9185 {
92- if ( ! s_publisherSource . HasListeners ( ) )
93- {
94- return null ;
95- }
96-
9786 Activity ? activity = linkedContext == default
9887 ? s_publisherSource . StartRabbitMQActivity (
9988 UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicPublish } { routingKey } " : MessagingOperationNameBasicPublish ,
@@ -111,11 +100,6 @@ public static class RabbitMQActivitySource
111100
112101 internal static Activity ? BasicGetEmpty ( string queue )
113102 {
114- if ( ! s_subscriberSource . HasListeners ( ) )
115- {
116- return null ;
117- }
118-
119103 Activity ? activity = s_subscriberSource . StartRabbitMQActivity (
120104 UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGetEmpty } { queue } " : MessagingOperationNameBasicGetEmpty ,
121105 ActivityKind . Consumer ) ;
@@ -133,11 +117,6 @@ public static class RabbitMQActivitySource
133117 internal static Activity ? BasicGet ( string routingKey , string exchange , ulong deliveryTag ,
134118 IReadOnlyBasicProperties readOnlyBasicProperties , int bodySize )
135119 {
136- if ( ! s_subscriberSource . HasListeners ( ) )
137- {
138- return null ;
139- }
140-
141120 // Extract the PropagationContext of the upstream parent from the message headers.
142121 Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
143122 UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGet } { routingKey } " : MessagingOperationNameBasicGet , ActivityKind . Consumer ,
@@ -154,11 +133,6 @@ public static class RabbitMQActivitySource
154133 internal static Activity ? Deliver ( string routingKey , string exchange , ulong deliveryTag ,
155134 IReadOnlyBasicProperties basicProperties , int bodySize )
156135 {
157- if ( ! s_subscriberSource . HasListeners ( ) )
158- {
159- return null ;
160- }
161-
162136 // Extract the PropagationContext of the upstream parent from the message headers.
163137 Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
164138 UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicDeliver } { routingKey } " : MessagingOperationNameBasicDeliver ,
@@ -172,17 +146,6 @@ public static class RabbitMQActivitySource
172146 return activity ;
173147 }
174148
175- internal static void ReportException ( this Activity activity , Exception exception )
176- {
177- ActivityTagsCollection exceptionTags = new ( ) ;
178- exceptionTags . Add ( new KeyValuePair < string , object ? > ( ExceptionMessageTag , exception . Message ) ) ;
179- exceptionTags . Add ( new KeyValuePair < string , object ? > ( ExceptionStackTraceTag , exception . ToString ( ) ) ) ;
180- exceptionTags . Add ( new KeyValuePair < string , object ? > ( ExceptionTypeTag , exception . GetType ( ) . ToString ( ) ) ) ;
181- activity . AddEvent ( new ActivityEvent ( ExceptionEventName , default , exceptionTags ) ) ;
182-
183- activity . SetStatus ( ActivityStatusCode . Error ) ;
184- }
185-
186149 private static Activity ? StartRabbitMQActivity ( this ActivitySource source , string name , ActivityKind kind ,
187150 ActivityContext parentContext = default )
188151 {
@@ -232,15 +195,15 @@ private static void PopulateMessagingTags(string operationType, string operation
232195
233196 internal static void PopulateMessageEnvelopeSize ( Activity ? activity , int size )
234197 {
235- if ( activity != null && activity . IsAllDataRequested && PublisherHasListeners )
198+ if ( activity ? . IsAllDataRequested ?? false )
236199 {
237200 activity . SetTag ( MessagingEnvelopeSize , size ) ;
238201 }
239202 }
240203
241204 internal static void SetNetworkTags ( this Activity ? activity , IFrameHandler frameHandler )
242205 {
243- if ( PublisherHasListeners && activity != null && activity . IsAllDataRequested )
206+ if ( activity ? . IsAllDataRequested ?? false )
244207 {
245208 switch ( frameHandler . RemoteEndPoint . AddressFamily )
246209 {
0 commit comments