5
5
from faststream .opentelemetry .middleware import TelemetryMiddleware
6
6
from faststream .types import AnyDict
7
7
from opentelemetry .metrics import Meter , MeterProvider
8
+ from opentelemetry .semconv ._incubating .attributes import messaging_attributes # noqa: PLC2701
8
9
from opentelemetry .semconv .trace import SpanAttributes
9
10
from opentelemetry .trace import TracerProvider
10
11
@@ -16,9 +17,9 @@ class StompTelemetrySettingsProvider(TelemetrySettingsProvider[stompman.MessageF
16
17
17
18
def get_consume_attrs_from_message (self , msg : StreamMessage [stompman .MessageFrame ]) -> "AnyDict" :
18
19
return {
19
- SpanAttributes .MESSAGING_SYSTEM : self .messaging_system ,
20
- SpanAttributes .MESSAGING_MESSAGE_ID : msg .message_id ,
21
- SpanAttributes .MESSAGING_MESSAGE_CONVERSATION_ID : msg .correlation_id ,
20
+ messaging_attributes .MESSAGING_SYSTEM : self .messaging_system ,
21
+ messaging_attributes .MESSAGING_MESSAGE_ID : msg .message_id ,
22
+ messaging_attributes .MESSAGING_MESSAGE_CONVERSATION_ID : msg .correlation_id ,
22
23
SpanAttributes .MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES : len (msg .body ),
23
24
MESSAGING_DESTINATION_PUBLISH_NAME : msg .raw_message .headers ["destination" ],
24
25
}
@@ -28,11 +29,11 @@ def get_consume_destination_name(self, msg: StreamMessage[stompman.MessageFrame]
28
29
29
30
def get_publish_attrs_from_kwargs (self , kwargs : StompProducerPublishKwargs ) -> AnyDict : # type: ignore[override]
30
31
publish_attrs = {
31
- SpanAttributes .MESSAGING_SYSTEM : self .messaging_system ,
32
- SpanAttributes .MESSAGING_DESTINATION_NAME : kwargs ["destination" ],
32
+ messaging_attributes .MESSAGING_SYSTEM : self .messaging_system ,
33
+ messaging_attributes .MESSAGING_DESTINATION_NAME : kwargs ["destination" ],
33
34
}
34
35
if kwargs ["correlation_id" ]:
35
- publish_attrs [SpanAttributes .MESSAGING_MESSAGE_CONVERSATION_ID ] = kwargs ["correlation_id" ]
36
+ publish_attrs [messaging_attributes .MESSAGING_MESSAGE_CONVERSATION_ID ] = kwargs ["correlation_id" ]
36
37
return publish_attrs
37
38
38
39
def get_publish_destination_name (self , kwargs : StompProducerPublishKwargs ) -> str : # type: ignore[override] # noqa: PLR6301
0 commit comments