Skip to content

Commit

Permalink
fix: correct RabbitExchange processing by OTEL in broker.publish case (
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Jun 14, 2024
1 parent bb6997f commit 2355603
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions faststream/rabbit/opentelemetry/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from opentelemetry.semconv.trace import SpanAttributes

Expand All @@ -9,6 +9,7 @@
from aio_pika import IncomingMessage

from faststream.broker.message import StreamMessage
from faststream.rabbit.schemas.exchange import RabbitExchange
from faststream.types import AnyDict


Expand Down Expand Up @@ -44,9 +45,12 @@ def get_publish_attrs_from_kwargs(
self,
kwargs: "AnyDict",
) -> "AnyDict":
exchange: Union[None, str, RabbitExchange] = kwargs.get("exchange")
return {
SpanAttributes.MESSAGING_SYSTEM: self.messaging_system,
SpanAttributes.MESSAGING_DESTINATION_NAME: kwargs.get("exchange") or "",
SpanAttributes.MESSAGING_DESTINATION_NAME: getattr(
exchange, "name", exchange or ""
),
SpanAttributes.MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY: kwargs[
"routing_key"
],
Expand Down

0 comments on commit 2355603

Please sign in to comment.