Esempio n. 1
0
        public void OrleansOnActivate([Object] KanekoExcuteData eventData)
        {
            var context = _tracingContext.CreateEntrySegmentContext(eventData.OperatioName, new HttpRequestCarrierHeaderCollection(eventData.SW8));

            context.Span.Component = GetComponent();
            context.Span.Peer      = new StringOrIntValue(eventData.GetRuntimeIdentity());
            context.Span.AddTag("grain.instance", eventData.GrainType);
            context.Span.AddTag("grain.identity", eventData.GrainId);
            context.Span.AddLog(LogEvent.Message($"Grain on activate"));
        }
        public void BeginRequest([Property] HttpContext httpContext)
        {
            var requestBody = httpContext.Request.GetBodyString();

            _segmentContext = _tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                        new HttpRequestCarrierHeaderCollection(httpContext.Request));
            var context = _segmentContext;

            if (!string.IsNullOrEmpty(requestBody))
            {
                context.Span.AddTag(TagsExtension.REQUEST, requestBody);
            }

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Component = Components.ASPNETCORE;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.Method);
            context.Span.AddTag(TagsExtension.HEADERS, JsonConvert.SerializeObject(httpContext.Request.Headers));
            context.Span.AddLog(
                LogEvent.Event("AspNetCore Hosting BeginRequest"),
                LogEvent.Message(
                    $"Request starting {httpContext.Request.Protocol} {httpContext.Request.Method} {httpContext.Request.GetDisplayUrl()}"));
        }
Esempio n. 3
0
        public void BeginRequest(ITracingContext tracingContext, HttpContext httpContext)
        {
            var context = tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                   new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Component = Common.Components.ASPNETCORE;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.Method);

            if (_config.CollectCookies?.Count > 0)
            {
                var cookies = CollectCookies(httpContext, _config.CollectCookies);
                if (!string.IsNullOrEmpty(cookies))
                {
                    context.Span.AddTag(Tags.HTTP_COOKIES, cookies);
                }
            }

            if (_config.CollectHeaders?.Count > 0)
            {
                var headers = CollectHeaders(httpContext, _config.CollectHeaders);
                if (!string.IsNullOrEmpty(headers))
                {
                    context.Span.AddTag(Tags.HTTP_HEADERS, headers);
                }
            }
        }
Esempio n. 4
0
        public void BeginRequest(ITracingContext tracingContext, HttpContext httpContext)
        {
            var context = tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                   new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.RPC_FRAMEWORK;
            context.Span.Component = Common.Components.GRPC;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
        }
Esempio n. 5
0
        public void OnInvoke(CInjection injection)
        {
            try
            {
                _context = _tracingContext.CreateEntrySegmentContext(injection.Method.Name, new TextCarrierHeaderCollection(new Dictionary <string, string>()));

                _injection = injection;
                _startTime = DateTime.Now;

                if (!Logger.IsDebugEnabled)
                {
                    return;
                }
                if (_injection == null)
                {
                    return;
                }
                if (!File.Exists(FileName))
                {
                    return;
                }
                if (!injection.IsValid())
                {
                    return;
                }

                var objectSearch = CachedSerializer.Deserialize <ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);
                if (objectSearch == null || objectSearch.PropertyNames == null)
                {
                    return;
                }

                _context.Span.AddTag("Method", injection.Method.Name);
                foreach (string propertyName in objectSearch.PropertyNames)
                {
                    var dictionary = _injection.GetPropertyValue(propertyName);
                    var method     = "";
                    var value      = "";
                    foreach (var key in dictionary.Keys)
                    {
                        method = string.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>");
                        Logger.Debug(method);

                        value += propertyName + "=" + dictionary[key] ?? "<null> /r/n ";
                    }

                    _context.Span.AddLog(LogEvent.Event($"{injection.Method.Name} :{value}"));
                }
            }
            catch (Exception ex)
            {
                Logger.Debug("OnInvoke ex:" + ex.Message);
                Logger.Error(ex);
            }
        }
        public void BeginRequest(ServerCallContext grpcContext)
        {
            var context = _tracingContext.CreateEntrySegmentContext(grpcContext.Method, new GrpcCarrierHeaderCollection(grpcContext.RequestHeaders));

            context.Span.SpanLayer = SpanLayer.RPC_FRAMEWORK;
            context.Span.Component = Components.GRPC;
            context.Span.Peer      = new StringOrIntValue(grpcContext.Peer);
            context.Span.AddTag(Tags.GRPC_METHOD_NAME, grpcContext.Method);
            context.Span.AddLog(
                LogEvent.Event("Grpc Server BeginRequest"),
                LogEvent.Message($"Request starting {grpcContext.Method}"));
        }
Esempio n. 7
0
        public void BeginRequest(ITracingContext tracingContext, HttpContext httpContext)
        {
            var context = tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                   new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Component = Common.Components.ASPNETCORE;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.Method);
        }
Esempio n. 8
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                var context = _tracingContext.CreateEntrySegmentContext(nameof(ExecuteAsync), new TextCarrierHeaderCollection(new Dictionary <string, string>()));

                await Task.Delay(1000, stoppingToken);

                context.Span.AddLog(LogEvent.Message($"Worker running at: {DateTime.Now}"));

                _tracingContext.Release(context);
            }
        }
Esempio n. 9
0
        public void BeforeServiceInvoke([Object] ServiceInvokeBeforeEventData eventData)
        {
            var operation = $"server-invoke: {eventData.Operation}";
            var context   = _tracingContext.CreateEntrySegmentContext(operation, new JimuServerCarrierHeaderCollection(eventData.Data.RemoteInvokeMessage.Payload));

            context.Span.Peer = eventData.Data.Address.ToString();

            if (eventData.Data.ServiceEntry != null)
            {
                context.Span.AddTag("service", eventData.Data.ServiceEntry.Descriptor.Id);
                context.Span.AddTag("allowAnonymous", eventData.Data.ServiceEntry.Descriptor.AllowAnonymous);
            }

            StringBuilder sbLog = new StringBuilder();

            if (eventData.Data.RemoteInvokeMessage?.Parameters != null)
            {
                sbLog.AppendLine($"parameters =>");
                foreach (var para in eventData.Data.RemoteInvokeMessage.Parameters)
                {
                    if (para.Value is List <JimuFile> )
                    {
                        foreach (var file in para.Value as List <JimuFile> )
                        {
                            sbLog.AppendLine($"{para.Key}: {file.FileName}");
                        }
                    }
                    else
                    {
                        sbLog.AppendLine($"{para.Key}: {para.Value}");
                    }
                }
            }

            sbLog.AppendLine($"token =>");
            sbLog.AppendLine($"{eventData.Data.RemoteInvokeMessage?.Token}");
            if (eventData.Data.RemoteInvokeMessage?.Payload?.Items != null)
            {
                sbLog.AppendLine($"payLoad =>");
                foreach (var item in eventData.Data.RemoteInvokeMessage.Payload.Items)
                {
                    sbLog.AppendLine($"{item.Key}: {item.Value}");
                }
            }
            else
            {
                sbLog.AppendLine($"payload is null");
            }

            context.Span.AddLog(LogEvent.Event("start"), LogEvent.Message(sbLog.ToString()));
        }
Esempio n. 10
0
        public void CapBeforeConsume([Object] CapEventDataSubStore eventData)
        {
            var carrierHeader = new CapCarrierHeaderCollection(eventData.TransportMessage);
            var context       = _tracingContext.CreateEntrySegmentContext(OperateNamePrefix + eventData.Operation + ConsumerOperateNameSuffix, carrierHeader);

            context.Span.SpanLayer = SpanLayer.MQ;
            context.Span.Component = GetComponent(eventData.BrokerAddress, false);
            context.Span.Peer      = eventData.BrokerAddress.Endpoint;
            context.Span.AddTag(Tags.MQ_TOPIC, eventData.Operation);
            context.Span.AddTag(Tags.MQ_BROKER, eventData.BrokerAddress.Endpoint);
            context.Span.AddLog(LogEvent.Event("Event Persistence"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence start..."));

            _contexts[eventData.TransportMessage.GetId()] = _entrySegmentContextAccessor.Context;
        }
Esempio n. 11
0
        public void BeginRequest([Property] HttpContext httpContext)
        {
            var context = _tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                    new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Component = Common.Components.ASPNETCORE;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.Method);
            context.Span.AddLog(
                LogEvent.Event("AspNetCore Hosting BeginRequest"),
                LogEvent.Message(
                    $"Request starting {httpContext.Request.Protocol} {httpContext.Request.Method} {httpContext.Request.GetDisplayUrl()}"));
        }
        public void CapBeforeConsume([Object] CapEventDataSubStore eventData)
        {
            var carrierHeader = new CapCarrierHeaderCollection(eventData.TransportMessage);
            var eventName     = eventData.TransportMessage.GetGroup() + "/" + eventData.Operation;
            var operationName = OperateNamePrefix + eventName + ConsumerOperateNameSuffix;
            var context       = _tracingContext.CreateEntrySegmentContext(operationName, carrierHeader);

            context.Span.SpanLayer = SpanLayer.DB;
            context.Span.Component = GetComponent(eventData.BrokerAddress, false);
            context.Span.Peer      = eventData.BrokerAddress.Endpoint.Replace("-1", "5672");
            context.Span.AddTag(Tags.MQ_TOPIC, eventData.Operation);
            context.Span.AddTag(Tags.MQ_BROKER, eventData.BrokerAddress.Endpoint);
            context.Span.AddLog(LogEvent.Event("Event Persistence Start"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence start..."));

            _contexts[eventData.TransportMessage.GetId() + eventData.TransportMessage.GetGroup()] = context;
        }
        public void ApplicationOnBeginRequest(object sender, EventArgs e)
        {
            var httpApplication = sender as HttpApplication;
            var httpContext     = httpApplication.Context;

            if (httpContext.Request.HttpMethod == "OPTIONS")
            {
                //asp.net Exclude OPTIONS request
                return;
            }
            var context = _tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                    new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Peer      = new StringOrIntValue(httpContext.Request.UserHostAddress);
            context.Span.Component = Common.Components.ASPNET;
            context.Span.AddTag(Tags.URL, httpContext.Request.Url.OriginalString);
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.HttpMethod);
            context.Span.AddLog(LogEvent.Event("AspNet BeginRequest"),
                                LogEvent.Message(
                                    $"Request starting {httpContext.Request.Url.Scheme} {httpContext.Request.HttpMethod} {httpContext.Request.Url.OriginalString}"));
        }
Esempio n. 14
0
        public void BeginRequest(ITracingContext tracingContext, HttpContext httpContext)
        {
            var context = tracingContext.CreateEntrySegmentContext(httpContext.Request.Path,
                                                                   new HttpRequestCarrierHeaderCollection(httpContext.Request));

            context.Span.SpanLayer = SpanLayer.HTTP;
            context.Span.Component = Common.Components.ASPNETCORE;
            context.Span.Peer      = new StringOrIntValue(httpContext.Connection.RemoteIpAddress.ToString());
            context.Span.AddTag(Tags.URL, httpContext.Request.GetDisplayUrl());
            context.Span.AddTag(Tags.PATH, httpContext.Request.Path);
            context.Span.AddTag(Tags.HTTP_METHOD, httpContext.Request.Method);

            if (_config.AutoTagCookies?.Count > 0)
            {
                foreach (var key in _config.AutoTagCookies)
                {
                    if (!httpContext.Request.Cookies.TryGetValue(key, out string value))
                    {
                        continue;
                    }
                    context.Span.AddTag("cookie." + key, value);
                }
            }
        }
        public void BeforeServiceInvoke([Object] ServiceInvokeBeforeEventData eventData)
        {
            var context = _tracingContext.CreateEntrySegmentContext(eventData.Operation, new JimuServerCarrierHeaderCollection(eventData.Data.RemoteInvokeMessage.Payload));

            context.Span.AddTag("name", "f**k");
        }