示例#1
0
        /// <inheritdoc />
        public ITransmissionResponse Transmit(ITransmissionMessage transmissionMessage)
        {
            Trace root = Trace.Create();

            root.Record(Annotations.ServiceName("transmit"));
            root.Record(Annotations.ClientSend());
            try
            {
                return(this.Perform(transmissionMessage, root));
            }
            finally
            {
                root.Record(Annotations.ClientRecv());
            }
        }
示例#2
0
        /// <inheritdoc />
        public ITransmissionResponse Transmit(ITransmissionMessage transmissionMessage, Trace root)
        {
            Trace span = root.Child();

            span.Record(Annotations.ServiceName("transmit"));
            span.Record(Annotations.ClientSend());
            try
            {
                return(this.Perform(transmissionMessage, span));
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
示例#3
0
 public DefaultTransmissionRequest(ITransmissionMessage transmissionMessage, Endpoint endpoint)
 {
     this.endpoint = endpoint;
     this.header   = transmissionMessage.GetHeader();
     this.payload  = transmissionMessage.GetPayload();
 }
示例#4
0
        private ITransmissionResponse Perform(ITransmissionMessage transmissionMessage, Trace root)
        {
            this.transmissionVerifier.Verify(transmissionMessage.GetHeader(), Direction.OUT);

            ITransmissionRequest transmissionRequest;

            if (transmissionMessage is ITransmissionRequest)
            {
                transmissionRequest = (ITransmissionRequest)transmissionMessage;
            }
            else
            {
                // Perform lookup using header.
                Trace lookupSpan = root.Child();
                lookupSpan.Record(Annotations.ServiceName("Fetch endpoint information"));
                lookupSpan.Record(Annotations.ClientSend());
                try
                {
                    var endpoint = this.lookupService.Lookup(transmissionMessage.GetHeader(), lookupSpan);
                    lookupSpan.Record(
                        Annotations.Tag("transport profile", endpoint.TransportProfile.Identifier));
                    transmissionRequest = new DefaultTransmissionRequest(transmissionMessage, endpoint);
                }
                catch (HyperwayTransmissionException e)
                {
                    lookupSpan.Record(Annotations.Tag("exception", e.Message));
                    throw;
                }
                finally
                {
                    lookupSpan.Record(Annotations.ClientRecv());
                }
            }

            Trace span = root.Child();

            span.Record(Annotations.ServiceName("send message"));
            span.Record(Annotations.ClientSend());

            // Span span = tracer.newChild(root.context()).name("send message").start();
            ITransmissionResponse transmissionResponse;

            try
            {
                TransportProfile transportProfile = transmissionRequest.GetEndpoint().TransportProfile;
                IMessageSender   messageSender    = this.messageSenderFactory.GetMessageSender(transportProfile);
                transmissionResponse = messageSender.Send(transmissionRequest, span);
            }
            catch (HyperwayTransmissionException e)
            {
                span.Record(Annotations.Tag("exception", e.Message));
                throw;
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }

            this.statisticsService.Persist(transmissionRequest, transmissionResponse, root);

            return(transmissionResponse);
        }