Пример #1
0
 async def request(self, target: PID, message: any) -> None:
     with OpenTracingHelper.build_started_scope(
             self._tracer, OpenTracingHelper.get_parent_span(self._tracer),
             'request', message, self._send_span_setup) as scope:
         try:
             scope.span.set_tag('proto.targetpid', target.to_short_string())
             await super().request(target, message)
         except Exception as ex:
             OpenTracingHelper.setup_span(ex, scope.span)
             raise Exception()
Пример #2
0
 async def request_future(
         self,
         target: PID,
         message: object,
         timeout: timedelta = None,
         cancellation_token: CancelToken = None) -> asyncio.Future:
     with OpenTracingHelper.build_started_scope(
             self._tracer, OpenTracingHelper.get_parent_span(self._tracer),
             'request_future', message, self._send_span_setup) as scope:
         try:
             scope.span.set_tag('proto.targetpid', target.to_short_string())
             return await super().request_future(target, message, timeout,
                                                 cancellation_token)
         except Exception as ex:
             OpenTracingHelper.setup_span(ex, scope.span)
             raise Exception()
Пример #3
0
    async def receive(self, envelope: MessageEnvelope) -> None:
        message = envelope.message
        parent_span_ctx = None
        if envelope.header is not None:
            parent_span_ctx = self._tracer.extract(format=Format.TEXT_MAP,
                                                   carrier=envelope.header)

        with OpenTracingHelper.build_started_scope(
                self._tracer, parent_span_ctx, 'receive', message,
                self._receive_span_setup) as scope:
            try:
                if envelope.sender is not None:
                    scope.span.set_tag('proto.senderpid',
                                       envelope.sender.to_short_string())
                if self._receive_span_setup is not None:
                    self._receive_span_setup(scope.span, message)
                await super().receive(envelope)
            except Exception as ex:
                OpenTracingHelper.setup_span(ex, scope.span)
                raise Exception()