@@ -15,6 +15,11 @@ public static class RabbitMQActivitySource
15
15
// https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes
16
16
internal const string MessageId = "messaging.message.id" ;
17
17
internal const string MessageConversationId = "messaging.message.conversation_id" ;
18
+ internal const string MessagingOperationName = "messaging.operation.name" ;
19
+ internal const string MessagingOperationNameBasicDeliver = "deliver" ;
20
+ internal const string MessagingOperationNameBasicGet = "fetch" ;
21
+ internal const string MessagingOperationNameBasicGetEmpty = "fetch (empty)" ;
22
+ internal const string MessagingOperationNameBasicPublish = "publish" ;
18
23
internal const string MessagingOperationType = "messaging.operation.type" ;
19
24
internal const string MessagingOperationTypeSend = "send" ;
20
25
internal const string MessagingOperationTypeProcess = "process" ;
@@ -56,7 +61,7 @@ public static class RabbitMQActivitySource
56
61
new KeyValuePair < string , object ? > ( ProtocolVersion , "0.9.1" )
57
62
} ;
58
63
59
- internal static Activity ? Send ( string routingKey , string exchange , int bodySize ,
64
+ internal static Activity ? BasicPublish ( string routingKey , string exchange , int bodySize ,
60
65
ActivityContext linkedContext = default )
61
66
{
62
67
if ( ! s_publisherSource . HasListeners ( ) )
@@ -66,41 +71,42 @@ public static class RabbitMQActivitySource
66
71
67
72
Activity ? activity = linkedContext == default
68
73
? s_publisherSource . StartRabbitMQActivity (
69
- UseRoutingKeyAsOperationName ? $ "{ routingKey } { MessagingOperationTypeSend } " : MessagingOperationTypeSend ,
74
+ UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicPublish } { routingKey } " : MessagingOperationNameBasicPublish ,
70
75
ActivityKind . Producer )
71
76
: s_publisherSource . StartLinkedRabbitMQActivity (
72
- UseRoutingKeyAsOperationName ? $ "{ routingKey } { MessagingOperationTypeSend } " : MessagingOperationTypeSend ,
77
+ UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicPublish } { routingKey } " : MessagingOperationNameBasicPublish ,
73
78
ActivityKind . Producer , linkedContext ) ;
74
79
if ( activity != null && activity . IsAllDataRequested )
75
80
{
76
- PopulateMessagingTags ( MessagingOperationTypeSend , routingKey , exchange , 0 , bodySize , activity ) ;
81
+ PopulateMessagingTags ( MessagingOperationTypeSend , MessagingOperationNameBasicPublish , routingKey , exchange , 0 , bodySize , activity ) ;
77
82
}
78
83
79
84
return activity ;
80
85
81
86
}
82
87
83
- internal static Activity ? ReceiveEmpty ( string queue )
88
+ internal static Activity ? BasicGetEmpty ( string queue )
84
89
{
85
90
if ( ! s_subscriberSource . HasListeners ( ) )
86
91
{
87
92
return null ;
88
93
}
89
94
90
95
Activity ? activity = s_subscriberSource . StartRabbitMQActivity (
91
- UseRoutingKeyAsOperationName ? $ "{ queue } { MessagingOperationTypeReceive } " : MessagingOperationTypeReceive ,
96
+ UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGetEmpty } { queue } " : MessagingOperationNameBasicGetEmpty ,
92
97
ActivityKind . Consumer ) ;
93
98
if ( activity != null && activity . IsAllDataRequested )
94
99
{
95
100
activity
96
101
. SetTag ( MessagingOperationType , MessagingOperationTypeReceive )
102
+ . SetTag ( MessagingOperationName , MessagingOperationNameBasicGetEmpty )
97
103
. SetTag ( MessagingDestination , "amq.default" ) ;
98
104
}
99
105
100
106
return activity ;
101
107
}
102
108
103
- internal static Activity ? Receive ( string routingKey , string exchange , ulong deliveryTag ,
109
+ internal static Activity ? BasicGet ( string routingKey , string exchange , ulong deliveryTag ,
104
110
IReadOnlyBasicProperties readOnlyBasicProperties , int bodySize )
105
111
{
106
112
if ( ! s_subscriberSource . HasListeners ( ) )
@@ -110,11 +116,11 @@ public static class RabbitMQActivitySource
110
116
111
117
// Extract the PropagationContext of the upstream parent from the message headers.
112
118
Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
113
- UseRoutingKeyAsOperationName ? $ "{ routingKey } { MessagingOperationTypeReceive } " : MessagingOperationTypeReceive , ActivityKind . Consumer ,
119
+ UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicGet } { routingKey } " : MessagingOperationNameBasicGet , ActivityKind . Consumer ,
114
120
ContextExtractor ( readOnlyBasicProperties ) ) ;
115
121
if ( activity != null && activity . IsAllDataRequested )
116
122
{
117
- PopulateMessagingTags ( MessagingOperationTypeReceive , routingKey , exchange , deliveryTag , readOnlyBasicProperties ,
123
+ PopulateMessagingTags ( MessagingOperationTypeReceive , MessagingOperationNameBasicGet , routingKey , exchange , deliveryTag , readOnlyBasicProperties ,
118
124
bodySize , activity ) ;
119
125
}
120
126
@@ -131,11 +137,11 @@ public static class RabbitMQActivitySource
131
137
132
138
// Extract the PropagationContext of the upstream parent from the message headers.
133
139
Activity ? activity = s_subscriberSource . StartLinkedRabbitMQActivity (
134
- UseRoutingKeyAsOperationName ? $ "{ routingKey } { MessagingOperationTypeProcess } " : MessagingOperationTypeProcess ,
140
+ UseRoutingKeyAsOperationName ? $ "{ MessagingOperationNameBasicDeliver } { routingKey } " : MessagingOperationNameBasicDeliver ,
135
141
ActivityKind . Consumer , ContextExtractor ( basicProperties ) ) ;
136
142
if ( activity != null && activity . IsAllDataRequested )
137
143
{
138
- PopulateMessagingTags ( MessagingOperationTypeProcess , routingKey , exchange ,
144
+ PopulateMessagingTags ( MessagingOperationTypeProcess , MessagingOperationNameBasicDeliver , routingKey , exchange ,
139
145
deliveryTag , basicProperties , bodySize , activity ) ;
140
146
}
141
147
@@ -157,10 +163,10 @@ public static class RabbitMQActivitySource
157
163
? . Start ( ) ;
158
164
}
159
165
160
- private static void PopulateMessagingTags ( string operation , string routingKey , string exchange ,
166
+ private static void PopulateMessagingTags ( string operationType , string operationName , string routingKey , string exchange ,
161
167
ulong deliveryTag , IReadOnlyBasicProperties readOnlyBasicProperties , int bodySize , Activity activity )
162
168
{
163
- PopulateMessagingTags ( operation , routingKey , exchange , deliveryTag , bodySize , activity ) ;
169
+ PopulateMessagingTags ( operationType , operationName , routingKey , exchange , deliveryTag , bodySize , activity ) ;
164
170
165
171
if ( ! string . IsNullOrEmpty ( readOnlyBasicProperties . CorrelationId ) )
166
172
{
@@ -173,11 +179,12 @@ private static void PopulateMessagingTags(string operation, string routingKey, s
173
179
}
174
180
}
175
181
176
- private static void PopulateMessagingTags ( string operation , string routingKey , string exchange ,
182
+ private static void PopulateMessagingTags ( string operationType , string operationName , string routingKey , string exchange ,
177
183
ulong deliveryTag , int bodySize , Activity activity )
178
184
{
179
185
activity
180
- . SetTag ( MessagingOperationType , operation )
186
+ . SetTag ( MessagingOperationType , operationType )
187
+ . SetTag ( MessagingOperationName , operationName )
181
188
. SetTag ( MessagingDestination , string . IsNullOrEmpty ( exchange ) ? "amq.default" : exchange )
182
189
. SetTag ( MessagingDestinationRoutingKey , routingKey )
183
190
. SetTag ( MessagingBodySize , bodySize ) ;
0 commit comments