Bases: TelemetrySettingsProvider['IncomingMessage', RabbitPublishCommand]
Source code in faststream/rabbit/opentelemetry/provider.py
| def __init__(self) -> None:
self.messaging_system = "rabbitmq"
|
messaging_system instance-attribute
messaging_system = 'rabbitmq'
get_consume_attrs_from_message
get_consume_attrs_from_message(
msg: StreamMessage[IncomingMessage],
) -> dict[str, Any]
Source code in faststream/rabbit/opentelemetry/provider.py
24
25
26
27
28
29
30
31
32
33
34
35
36 | def get_consume_attrs_from_message(
self,
msg: "StreamMessage[IncomingMessage]",
) -> dict[str, Any]:
return {
SpanAttributes.MESSAGING_SYSTEM: self.messaging_system,
SpanAttributes.MESSAGING_MESSAGE_ID: msg.message_id,
SpanAttributes.MESSAGING_MESSAGE_CONVERSATION_ID: msg.correlation_id,
SpanAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES: len(msg.body),
SpanAttributes.MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY: msg.raw_message.routing_key,
"messaging.rabbitmq.message.delivery_tag": msg.raw_message.delivery_tag,
MESSAGING_DESTINATION_PUBLISH_NAME: msg.raw_message.exchange,
}
|
get_consume_destination_name
get_consume_destination_name(
msg: StreamMessage[IncomingMessage],
) -> str
Source code in faststream/rabbit/opentelemetry/provider.py
| @override
def get_consume_destination_name(
self,
msg: "StreamMessage[IncomingMessage]",
) -> str:
exchange = msg.raw_message.exchange or "default"
routing_key = msg.raw_message.routing_key
return f"{exchange}.{routing_key}"
|
get_publish_attrs_from_cmd
Source code in faststream/rabbit/opentelemetry/provider.py
47
48
49
50
51
52
53
54
55
56 | def get_publish_attrs_from_cmd(
self,
cmd: "RabbitPublishCommand",
) -> dict[str, Any]:
return {
SpanAttributes.MESSAGING_SYSTEM: self.messaging_system,
SpanAttributes.MESSAGING_DESTINATION_NAME: cmd.exchange.name,
SpanAttributes.MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY: cmd.destination,
SpanAttributes.MESSAGING_MESSAGE_CONVERSATION_ID: cmd.correlation_id,
}
|
get_publish_destination_name
Source code in faststream/rabbit/opentelemetry/provider.py
| @override
def get_publish_destination_name(
self,
cmd: "RabbitPublishCommand",
) -> str:
return f"{cmd.exchange.name or 'default'}.{cmd.destination}"
|