-
Notifications
You must be signed in to change notification settings - Fork 626
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
Support aio-pika 9.1 #1835
Comments
In the meantime, here is a fix that will work to override the method. First create this from aio_pika.abc import AbstractChannel
from opentelemetry.semconv.trace import SpanAttributes
def patch_spanbuilder_set_channel() -> None:
"""
The default SpanBuilder.set_channel does not work with aio_pika 9.1 and the refactored connection
attribute
"""
import opentelemetry.instrumentation.aio_pika.span_builder
from opentelemetry.instrumentation.aio_pika.span_builder import SpanBuilder
def set_channel(self: SpanBuilder, channel: AbstractChannel) -> None:
if hasattr(channel, "_connection"):
url = channel._connection.url
self._attributes.update(
{
SpanAttributes.NET_PEER_NAME: url.host,
SpanAttributes.NET_PEER_PORT: url.port,
}
)
opentelemetry.instrumentation.aio_pika.span_builder.SpanBuilder.set_channel = set_channel # type: ignore[misc] Add an ENTRYPOINT in your project to pre_instrument. In Poetry it looks like this in [tool.poetry.plugins."opentelemetry_pre_instrument"]
aio_pika = "package.path.to.patch_spanbuilder_set_channel" |
Any ETA on this? |
I'm also interested in this being resolved. Would it be appropriate to bump the comment at mosquito/aio-pika#533 (comment) since it seems that we're close to a resolution but have yet to get a reply from the aio-pika maintainers. |
This should be: from aio_pika.abc import AbstractChannel
from opentelemetry.semconv.trace import SpanAttributes
def patch_spanbuilder_set_channel() -> None:
"""
The default SpanBuilder.set_channel does not work with aio_pika 9.1 and the refactored connection
attribute
"""
import opentelemetry.instrumentation.aio_pika.span_builder
from opentelemetry.instrumentation.aio_pika.span_builder import SpanBuilder
def set_channel(self: SpanBuilder, channel: AbstractChannel) -> None:
if hasattr(channel, "_connection"):
url = channel._connection.url
port = url.port or 5672
self._attributes.update(
{
SpanAttributes.NET_PEER_NAME: url.host,
SpanAttributes.NET_PEER_PORT: port,
}
)
opentelemetry.instrumentation.aio_pika.span_builder.SpanBuilder.set_channel = set_channel # type: ignore[misc] thank you for your valuable fix the pyproject.toml change can be omitted for users who directly invoke instrumentation: patch_spanbuilder_set_channel()
AioPikaInstrumentor().instrument() is also sufficient |
While there is the PR, somehow it still seems to be an issue with |
@RedLine89 the fix is not yet apart of a release but will be in 0.46b0. I’m unsure of the release schedule. |
Should this issue not be closed now that #2450 has been merged? |
Yes, it should be. |
@phillipuniverse Can you close this? |
@gchadid could you please open a new issue for this? |
Is your feature request related to a problem?
The aio-pika instrumentation is currently broken for publish and consume spans in aio-pika 9.1+. This is due to a refactoring of connection properties on a channel in the 9.1.0 release.
Here's the exception:
Describe the solution you'd like
Otel working with aio-pika 9.1
Describe alternatives you've considered
N/A
Additional context
I asked for clarification on the aio-pika maintainer's opinion of the correct fix at mosquito/aio-pika#533 (comment)
The text was updated successfully, but these errors were encountered: