Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct RabbitExchange processing by OTEL in broker.publish case #1521

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading