Skip to content

BatchNatsMetricsSettingsProvider

faststream.nats.prometheus.provider.BatchNatsMetricsSettingsProvider #

BatchNatsMetricsSettingsProvider()

Bases: BaseNatsMetricsSettingsProvider[List['Msg']]

Source code in faststream/nats/prometheus/provider.py
def __init__(self) -> None:
    self.messaging_system = "nats"

messaging_system instance-attribute #

messaging_system = 'nats'

get_publish_destination_name_from_kwargs #

get_publish_destination_name_from_kwargs(kwargs)
Source code in faststream/nats/prometheus/provider.py
def get_publish_destination_name_from_kwargs(
    self,
    kwargs: "AnyDict",
) -> str:
    return cast(str, kwargs["subject"])

get_consume_attrs_from_message #

get_consume_attrs_from_message(msg)
Source code in faststream/nats/prometheus/provider.py
def get_consume_attrs_from_message(
    self,
    msg: "StreamMessage[List[Msg]]",
) -> ConsumeAttrs:
    raw_message = msg.raw_message[0]
    return {
        "destination_name": raw_message.subject,
        "message_size": len(msg.body),
        "messages_count": len(msg.raw_message),
    }