@@ -63,7 +63,6 @@ public static class RabbitMQActivitySource
63
63
DefaultContextExtractor ;
64
64
65
65
public static bool UseRoutingKeyAsOperationName { get ; set ; } = true ;
66
- internal static bool PublisherHasListeners => s_publisherSource . HasListeners ( ) ;
67
66
68
67
internal static readonly IEnumerable < KeyValuePair < string , object ? > > CreationTags = new [ ]
69
68
{
@@ -74,11 +73,6 @@ public static class RabbitMQActivitySource
74
73
75
74
internal static Activity ? OpenConnection ( IFrameHandler frameHandler )
76
75
{
77
- if ( ! s_connectionSource . HasListeners ( ) )
78
- {
79
- return null ;
80
- }
81
-
82
76
Activity ? connectionActivity =
83
77
s_connectionSource . StartRabbitMQActivity ( "connection attempt" , ActivityKind . Client ) ;
84
78
connectionActivity ?
@@ -89,11 +83,6 @@ public static class RabbitMQActivitySource
89
83
internal static Activity ? BasicPublish ( string routingKey , string exchange , int bodySize ,
90
84
ActivityContext linkedContext = default )
91
85
{
92
- if ( ! s_publisherSource . HasListeners ( ) )
93
- {
94
- return null ;
95
- }
96
-
97
86
Activity ? activity = linkedContext == default
98
87
? s_publisherSource . StartRabbitMQActivity (
99
88
UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicPublish } { routingKey } " : MessagingOperationNameBasicPublish ,
@@ -111,11 +100,6 @@ public static class RabbitMQActivitySource
111
100
112
101
internal static Activity ? BasicGetEmpty ( string queue )
113
102
{
114
- if ( ! s_subscriberSource . HasListeners ( ) )
115
- {
116
- return null ;
117
- }
118
-
119
103
Activity ? activity = s_subscriberSource . StartRabbitMQActivity (
120
104
UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGetEmpty } { queue } " : MessagingOperationNameBasicGetEmpty ,
121
105
ActivityKind . Consumer ) ;
@@ -133,11 +117,6 @@ public static class RabbitMQActivitySource
133
117
internal static Activity ? BasicGet ( string routingKey , string exchange , ulong deliveryTag ,
134
118
IReadOnlyBasicProperties readOnlyBasicProperties , int bodySize )
135
119
{
136
- if ( ! s_subscriberSource . HasListeners ( ) )
137
- {
138
- return null ;
139
- }
140
-
141
120
// Extract the PropagationContext of the upstream parent from the message headers.
142
121
Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
143
122
UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGet } { routingKey } " : MessagingOperationNameBasicGet , ActivityKind . Consumer ,
@@ -154,11 +133,6 @@ public static class RabbitMQActivitySource
154
133
internal static Activity ? Deliver ( string routingKey , string exchange , ulong deliveryTag ,
155
134
IReadOnlyBasicProperties basicProperties , int bodySize )
156
135
{
157
- if ( ! s_subscriberSource . HasListeners ( ) )
158
- {
159
- return null ;
160
- }
161
-
162
136
// Extract the PropagationContext of the upstream parent from the message headers.
163
137
Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
164
138
UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicDeliver } { routingKey } " : MessagingOperationNameBasicDeliver ,
@@ -172,17 +146,6 @@ public static class RabbitMQActivitySource
172
146
return activity ;
173
147
}
174
148
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
-
186
149
private static Activity ? StartRabbitMQActivity ( this ActivitySource source , string name , ActivityKind kind ,
187
150
ActivityContext parentContext = default )
188
151
{
@@ -232,15 +195,15 @@ private static void PopulateMessagingTags(string operationType, string operation
232
195
233
196
internal static void PopulateMessageEnvelopeSize ( Activity ? activity , int size )
234
197
{
235
- if ( activity != null && activity . IsAllDataRequested && PublisherHasListeners )
198
+ if ( activity ? . IsAllDataRequested ?? false )
236
199
{
237
200
activity . SetTag ( MessagingEnvelopeSize , size ) ;
238
201
}
239
202
}
240
203
241
204
internal static void SetNetworkTags ( this Activity ? activity , IFrameHandler frameHandler )
242
205
{
243
- if ( PublisherHasListeners && activity != null && activity . IsAllDataRequested )
206
+ if ( activity ? . IsAllDataRequested ?? false )
244
207
{
245
208
switch ( frameHandler . RemoteEndPoint . AddressFamily )
246
209
{
0 commit comments