Exemplo n.º 1
0
        private void WirteDiagnosticBefore(TransportMessage message)
        {
            if (!AppConfig.ServerOptions.DisableDiagnostic)
            {
                var remoteInvokeMessage = message.GetContent <RemoteInvokeMessage>();
                remoteInvokeMessage.Attachments.TryGetValue("TraceId", out object traceId);
                _diagnosticListener.WriteTransportBefore(TransportType.Rpc, new TransportEventData(new DiagnosticMessage
                {
                    Content     = message.Content,
                    ContentType = message.ContentType,
                    Id          = message.Id,
                    MessageName = remoteInvokeMessage.ServiceId
                }, remoteInvokeMessage.DecodeJOject ? RpcMethod.Json_Rpc.ToString() : RpcMethod.Proxy_Rpc.ToString(),
                                                                                                   traceId?.ToString(),
                                                                                                   RpcContext.GetContext().GetAttachment("RemoteAddress")?.ToString()));
            }
            var parameters = RpcContext.GetContext().GetContextParameters();

            parameters.TryRemove("RemoteAddress", out object value);
            RpcContext.GetContext().SetContextParameters(parameters);
        }
Exemplo n.º 2
0
        private void WirteDiagnosticBefore(TransportMessage message)
        {
            var diagnosticListener  = new DiagnosticListener(DiagnosticListenerExtensions.DiagnosticListenerName);
            var remoteInvokeMessage = message.GetContent <RemoteInvokeMessage>();

            diagnosticListener.WriteTransportBefore(TransportType.Rpc, new TransportEventData(new DiagnosticMessage
            {
                Content     = message.Content,
                ContentType = message.ContentType,
                Id          = message.Id,
                MessageName = remoteInvokeMessage.ServiceId
            }, remoteInvokeMessage.DecodeJOject?RpcMethod.Json_Rpc.ToString():RpcMethod.Proxy_Rpc.ToString(), RpcContext.GetContext().GetAttachment("RemoteAddress")?.ToString()));
        }