Example #1
0
 public Selector(ServerRequestEventModel serverRequestEventModel, EventType eventType)
 {
     Type         = eventType == EventType.Client ? nameof(ClientRequestEventModel) : nameof(ServerRequestEventModel);
     From         = serverRequestEventModel.From.Service;
     To           = serverRequestEventModel.System.Service;
     Method       = serverRequestEventModel.From.TargetMethod;
     ParentSpanId = serverRequestEventModel.ParentSpanId;
     Span         = serverRequestEventModel.SpanId;
 }
Example #2
0
        public IEnumerable <EventModel> Convert(IEnumerable <RowEvent> events)
        {
            List <EventModel> convertEvent = new List <EventModel>();

            foreach (var evt in events)
            {
                EventModel temp = null;
                switch (evt.source.type)
                {
                case "serverReq":
                    try
                    {
                        temp = new ServerRequestEventModel()
                        {
                            From =
                                new Caller()
                            {
                                Service      = evt.source.cln.system,
                                Host         = evt.source.cln.host,
                                TargetMethod = evt.source.target.method
                            },
                            Parameters = evt.source?._params?.AdditionalData.ToDictionary(x => x.Key, x => x.Value.ToString())
                        };
                    }
                    catch (Exception)
                    {
                        //   Console.WriteLine(e);
                    }

                    break;

                case "log":
                    temp = new LogEventModel
                    {
                        LineNumber = evt.source.loc?.line,
                        Method     = evt.source.loc?.method,
                        Flie       = evt.source.loc?.file
                    };
                    break;

                case "request":
                    temp = new RequestEventModel {
                        Path = evt.source.httpReq?.path
                    };

                    break;

                case "clientReq":
                    temp = new ClientRequestEventModel()
                    {
                        To =
                            new Target()
                        {
                            Service = evt.source.target.service,
                            Host    = evt.source.target.host,
                            Method  = evt.source.target.method
                        }
                    };

                    break;
                }

                if (temp != null)
                {
                    convertEvent.Add(temp);
                    temp.ParentSpanId = evt.source.pspanID;
                    temp.SpanId       = evt.source.spanID;
                    temp.System       = new Events.System
                    {
                        Service = evt.source.srv.system,
                        Host    = evt.source.srv.host
                    };
                    temp.Timestamp   = evt.source.timestamp;
                    temp.TotalTimeMs = evt.source?.stats?.total?.time ?? 0;
                    temp.Type        = evt.source.type;
                    temp.CreateBy    = EventModel.Create.Real;
                    temp.Priority    = evt.source.priority;
                    temp.Message     = evt.source.message;
                    temp.Endpoint    = evt.source.endpoint;
                    temp.ErrCode     = evt.source.errCode;
                    temp.Exception   = new ExceptionInfo
                    {
                        Type    = evt.source.ex?.type,
                        Message = evt.source.ex?.message,
                        //     StackTrace =
                    };
                }
            }

            return(convertEvent);
        }