@@ -65,12 +65,18 @@ public static class RabbitMQActivitySource
6565 new KeyValuePair < string , object ? > ( ProtocolVersion , "0.9.1" )
6666 } ;
6767
68- internal static Activity ? OpenConnection ( IFrameHandler frameHandler )
68+ internal static Activity ? OpenConnection ( bool isReconnection )
6969 {
7070 Activity ? connectionActivity =
7171 s_connectionSource . StartRabbitMQActivity ( "connection attempt" , ActivityKind . Client ) ;
72- connectionActivity ?
73- . SetNetworkTags ( frameHandler ) ;
72+ connectionActivity ? . SetTag ( "messaging.rabbitmq.connection.is_reconnection" , isReconnection ) ;
73+ return connectionActivity ;
74+ }
75+
76+ internal static Activity ? OpenTcpConnection ( )
77+ {
78+ Activity ? connectionActivity =
79+ s_connectionSource . StartRabbitMQActivity ( "tcp connection attempt" , ActivityKind . Client ) ;
7480 return connectionActivity ;
7581 }
7682
@@ -199,24 +205,7 @@ internal static void SetNetworkTags(this Activity? activity, IFrameHandler frame
199205 {
200206 if ( activity ? . IsAllDataRequested ?? false )
201207 {
202- switch ( frameHandler . RemoteEndPoint . AddressFamily )
203- {
204- case AddressFamily . InterNetworkV6 :
205- activity . SetTag ( "network.type" , "ipv6" ) ;
206- break ;
207- case AddressFamily . InterNetwork :
208- activity . SetTag ( "network.type" , "ipv4" ) ;
209- break ;
210- }
211-
212- if ( ! string . IsNullOrEmpty ( frameHandler . Endpoint . HostName ) )
213- {
214- activity
215- . SetTag ( "server.address" , frameHandler . Endpoint . HostName ) ;
216- }
217-
218- activity
219- . SetTag ( "server.port" , frameHandler . Endpoint . Port ) ;
208+ activity . SetServerTags ( frameHandler . Endpoint ) ;
220209
221210 if ( frameHandler . RemoteEndPoint is IPEndPoint ipEndpoint )
222211 {
@@ -244,6 +233,28 @@ internal static void SetNetworkTags(this Activity? activity, IFrameHandler frame
244233 }
245234 }
246235
236+ internal static void SetServerTags ( this Activity activity , AmqpTcpEndpoint endpoint )
237+ {
238+ switch ( endpoint . AddressFamily )
239+ {
240+ case AddressFamily . InterNetworkV6 :
241+ activity . SetTag ( "network.type" , "ipv6" ) ;
242+ break ;
243+ case AddressFamily . InterNetwork :
244+ activity . SetTag ( "network.type" , "ipv4" ) ;
245+ break ;
246+ }
247+
248+ if ( ! string . IsNullOrEmpty ( endpoint . HostName ) )
249+ {
250+ activity
251+ . SetTag ( "server.address" , endpoint . HostName ) ;
252+ }
253+
254+ activity
255+ . SetTag ( "server.port" , endpoint . Port ) ;
256+ }
257+
247258 private static void DefaultContextInjector ( Activity sendActivity , IDictionary < string , object ? > props )
248259 {
249260 DistributedContextPropagator . Current . Inject ( sendActivity , props , DefaultContextSetter ) ;
0 commit comments