Skip to content

Commit 9e59ba6

Browse files
UOndroAidan Jensen
authored andcommitted
Test calling code first
1 parent ce09c31 commit 9e59ba6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def _intercept_server_stream(
217217
stream = invoker(request_or_iterator, metadata)
218218

219219
def done_callback(future, span_):
220+
logger.exception("done_callback")
220221
try:
221222
future.result()
222223
except grpc.FutureCancelledError:

instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# pylint:disable=cyclic-import
15+
import logging
1516
from time import sleep
1617

1718
from unittest import mock
@@ -100,9 +101,7 @@ def setUp(self):
100101
self.server.start()
101102
# use a user defined interceptor along with the opentelemetry client interceptor
102103
interceptors = [Interceptor()]
103-
self.channel = grpc.insecure_channel("localhost:25565", options=[
104-
# (grpc.experimental.ChannelOptions.SingleThreadedUnaryStream, 1)
105-
])
104+
self.channel = grpc.insecure_channel("localhost:25565")
106105
self.channel = grpc.intercept_channel(self.channel, *interceptors)
107106
self._stub = test_server_pb2_grpc.GRPCTestServerStub(self.channel)
108107

@@ -175,14 +174,16 @@ def test_unary_stream(self):
175174
)
176175

177176
def test_unary_stream_can_be_cancel(self):
178-
responses = server_streaming_method(self._stub)
177+
responses = server_streaming_method(self._stub, serialize=False)
179178
for i, _ in enumerate(responses):
180179
if i == 1:
181180
responses.cancel()
182181
break
183-
sleep(10)
184-
self.server.stop(None)
185-
self.channel.close()
182+
self.assertEqual(responses.code(), grpc.StatusCode.CANCELLED)
183+
# self.server.stop(None)
184+
# self.channel.close()
185+
logging.exception("Getting spans")
186+
# sleep(10)
186187
spans = self.memory_exporter.get_finished_spans()
187188
self.assertEqual(len(spans), 1)
188189
span = spans[0]

0 commit comments

Comments
 (0)