Skip to content

RabbitMetricsSettingsProvider

faststream.rabbit.prometheus.provider.RabbitMetricsSettingsProvider #

RabbitMetricsSettingsProvider()

Bases: MetricsSettingsProvider['IncomingMessage']

Source code in faststream/rabbit/prometheus/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)
Source code in faststream/rabbit/prometheus/provider.py
def get_consume_attrs_from_message(
    self,
    msg: "StreamMessage[IncomingMessage]",
) -> ConsumeAttrs:
    exchange = msg.raw_message.exchange or "default"
    routing_key = msg.raw_message.routing_key

    return {
        "destination_name": f"{exchange}.{routing_key}",
        "message_size": len(msg.body),
        "messages_count": 1,
    }

get_publish_destination_name_from_kwargs #

get_publish_destination_name_from_kwargs(kwargs)
Source code in faststream/rabbit/prometheus/provider.py
def get_publish_destination_name_from_kwargs(
    self,
    kwargs: "AnyDict",
) -> str:
    exchange: Union[None, str, RabbitExchange] = kwargs.get("exchange")
    exchange_prefix = getattr(exchange, "name", exchange or "default")

    routing_key: str = kwargs["routing_key"]

    return f"{exchange_prefix}.{routing_key}"