You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My interpretation of the if not result: is that it's mainly acting as an indication that there was an exception; at any rate, in my simple use case, spans seem to start and end correctly if I change it to if result is None:.
Describe your environment
OS: MacOS
Python version: 3.12.9
Package version: commit
a5474c3b290f5fcd7b5e8f9953ae8b2891c374c0
google-cloud-pubsub 2.28.0
What happened?
When instrumenting Google Cloud PubSub, I see a lot of log messages
Calling end() on an ended span.
.This appears to happen whenever no messages are available after a PubSub call:
This appears to be due to
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_client.py
Lines 168 to 169 in a5474c3
which ends the span when
result
evaluates falsy.But then since there was no exception, program flow continues to
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_client.py
Line 122 in a5474c3
span.end()
.My interpretation of the
if not result:
is that it's mainly acting as an indication that there was an exception; at any rate, in my simple use case, spans seem to start and end correctly if I change it toif result is None:
.Steps to Reproduce
(This relies on an empty queue. I'm not familiar enough with gRPC to create a fully standalone test at this point)
Expected Result
Only a single
span.end()
call for each span created.Actual Result
span.end()
is called twice when result contains no messages.Additional context
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: