public void AfterExecuteCommand([Object] CommandSucceededEvent @event)
        {
            var context = _contextAccessor.Context;

            context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok");

            _tracingContext.Release(context);
        }
 public void ExcuteAfter([Object]ExcuteData eventData)
 {
     var context = _localSegmentContextAccessor.Context;
     if (context != null)
     {
         _tracingContext.Release(context);
     }
 }
        public void AfterExecuteCommand([Object] CommandSucceededEvent @event)
        {
            if (_contextMap.TryRemove(@event.RequestId, out var context))
            {
                context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok");

                _tracingContext.Release(context);
            }
        }
        public void AfterExecuteCommand()
        {
            var context = _contextAccessor.Context;

            if (context != null)
            {
                _tracingContext.Release(context);
            }
        }
        public void AfterExecuteCommand()
        {
            var Context = Accessor.Context;

            if (Context == null)
            {
                return;
            }
            TracingContext.Release(Context);
        }
        public void AfterServiceInvoke([Object] ServiceInvokeBeforeEventData eventData)
        {
            var context = _entrySegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }
            _tracingContext.Release(context);
        }
예제 #7
0
        public void AfterExecuteCommand()
        {
            var context = _contextAccessor.Context;

            if (context != null)
            {
                context.Span.AddLog(LogEvent.Event("Sql Invoke End"));
                _tracingContext.Release(context);
            }
        }
        public void MethodEndInvoke([Object] Object data)
        {
            var Context = Accessor.Context;

            if (Context == null)
            {
                return;
            }
            Context.ResultContext.SetResult(data);
            TracingContext.Release(Context);
        }
예제 #9
0
        public void ExecuteAfter([Property(Name = "ElapsedMilliseconds")] long?elapsedMilliseconds)
        {
            var context = _contextAccessor.Context;

            if (context != null)
            {
                context.Span.AddLog(LogEvent.Event(DiagnosticStrings.AfterExecute.Split(' ').Last()));
                context.Span.AddLog(LogEvent.Message($"耗时:{elapsedMilliseconds}ms"));
                _tracingContext.Release(context);
            }
        }
        public void ExcuteSocketBeginEnd([Object] Object data)
        {
            var Context = Accessor.Context;

            if (Context == null)
            {
                return;
            }
            Context.ResultContext.SetResult(data);
            TracingContext.Release(Context);
        }
예제 #11
0
        public void AfterExecuteCommand([Object] CommandSucceededEvent @event)
        {
            var context = _contextAccessor.Context;

            if (context == null)
            {
                _segmentContextMap.TryRemove((@event.OperationId ?? 0) + @event.RequestId, out context);
            }
            context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok");

            _tracingContext.Release(context);
        }
예제 #12
0
        public void OrleansInvokeAfter([Object] KanekoExcuteData eventData)
        {
            var context = _entrySegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Message($"Grain finished spend time: " + eventData.ElapsedTimeMs + "ms"));
            _tracingContext.Release(context);
        }
        public void ExecuteAfter([Property(Name = "ElapsedMilliseconds")] long?elapsedMilliseconds)
        {
            var context = _contextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event($"{DiagnosticStrings.AfterExecute.Split(' ').Last()}: {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"));
            context.Span.AddLog(LogEvent.Message($"elapsedMilliseconds: {elapsedMilliseconds}ms"));
            _tracingContext.Release(context);
        }
예제 #14
0
        public void CurdAfter([Object] CurdAfterEventArgs eventData)
        {
            var context = _localSegmentContextAccessor.Context;

            if (context != null)
            {
                if (eventData?.Exception != null)
                {
                    context.Span.ErrorOccurred(eventData.Exception, _tracingConfig);
                }
                _tracingContext.Release(context);
            }
        }
        public void CommandExecuted([Object] CommandExecutedEventData EventData)
        {
            if (EventData == null)
            {
                return;
            }
            var Context = GetCurrentContext(EventData.Command);

            Context.Context.Add("Duration", Math.Truncate(EventData.Duration.TotalMilliseconds).ToString());
            if (Context != null)
            {
                TracingContext.Release(Context);
            }
        }
        public void EndRequest()
        {
            var context = _segmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(
                LogEvent.Event("Grpc Client EndRequest"),
                LogEvent.Message($"Request finished "));

            _tracingContext.Release(context);
        }
        public void FinishCall([Property(Name = "Response")] HttpResponseMessage response)
        {
            var context = _contextAccessor.Context;

            if (context == null)
            {
                return;
            }

            var activity = Activity.Current;

            if (activity.OperationName == GrpcDiagnostics.ActivityName)
            {
                var statusCodeTag = activity.Tags.FirstOrDefault(x => x.Key == GrpcDiagnostics.GrpcStatusCodeTagName).Value;

                var statusCode = int.TryParse(statusCodeTag, out var code) ? code : -1;
                if (statusCode != 0)
                {
                    var err = ((StatusCode)statusCode).ToString();
                    context.Span.ErrorOccurred(new Exception(err), _tracingConfig);
                }

                context.Span.AddTag(Tags.GRPC_STATUS, statusCode);
            }

            _tracingContext.Release(context);
        }
예제 #18
0
        public void HttpResponse([Property(Name = "Response")] HttpResponseMessage response)
        {
            var context = _segmentContext;

            if (context == null)
            {
                return;
            }

            if (response != null)
            {
                var statusCode = (int)response.StatusCode;
                if (statusCode >= 400)
                {
                    context.Span.ErrorOccurred();
                }

                if (response.Content != null)
                {
                    var responseStr = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
                    context.Span.AddTag(TagsExtension.RESPONSE, responseStr);
                }

                context.Span.AddTag(Tags.STATUS_CODE, statusCode);
            }

            _tracingContext.Release(context);
        }
        public void HttpResponse([Property(Name = "Response")] HttpResponseMessage response)
        {
            var context = _contextAccessor.Context;

            if (context == null)
            {
                return;
            }

            if (response != null)
            {
                var statusCode = (int)response.StatusCode;
                if (statusCode >= 400)
                {
                    context.Span.ErrorOccurred();
                }

                context.Span.AddTag(Tags.STATUS_CODE, statusCode);

                if (response.Content != null && _httpClientDiagnosticConfig.CollectResponseBodyContentTypes?.Count > 0)
                {
                    var responseBody = response.Content.TryCollectAsString(
                        _httpClientDiagnosticConfig.CollectResponseBodyContentTypes,
                        _httpClientDiagnosticConfig.CollectBodyLengthThreshold);
                    if (!string.IsNullOrEmpty(responseBody))
                    {
                        context.Span.AddTag(Tags.HTTP_RESPONSE_BODY, responseBody);
                    }
                }
            }

            _tracingContext.Release(context);
        }
        public void HttpResponse([Property(Name = "Response")] HttpResponseMessage response)
        {
            var Context = Accessor.Context;

            if (Context == null)
            {
                return;
            }
            if (response != null)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Context.Context.Add(new Exception(response.Content.ReadAsStringAsync().Result));
                }
                Context.Context.Add("StatusCode", response.StatusCode.ToString());
            }
            TracingContext.Release(Context);
        }
예제 #21
0
        public void EndRequest([Property] HttpContext httpContext)
        {
            var Context = Accessor.Context;

            if (Context == null)
            {
                return;
            }
            foreach (var handler in DiagnosticHandlers)
            {
                if (handler.OnlyMatch(httpContext))
                {
                    handler.EndRequest(Context, httpContext);
                    break;
                }
            }
            TracingContext.Release(Context);
        }
예제 #22
0
        public void OnComplete()
        {
            if (_injection != null && _injection.IsValid())
            {
                Logger.Info(string.Format("{0} executed in {1} mSec", _injection.Method.Name, DateTime.Now.Subtract(_startTime).TotalMilliseconds));
            }

            _context.Span.AddLog(LogEvent.Message($"OnComplete running at: {DateTime.Now} ,executed in {DateTime.Now.Subtract(_startTime).TotalMilliseconds}"));
            _tracingContext.Release(_context);
        }
        public void EndRequest(ServerCallContext grpcContext)
        {
            var context = _segmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }
            var statusCode = grpcContext.Status.StatusCode;

            if (statusCode != StatusCode.OK)
            {
                context.Span.ErrorOccurred();
            }

            context.Span.AddTag(Tags.GRPC_STATUS, statusCode.ToString());
            context.Span.AddLog(
                LogEvent.Event("Grpc Server EndRequest"),
                LogEvent.Message($"Request finished {statusCode} "));

            _tracingContext.Release(context);
        }
예제 #24
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);
            }
        }
예제 #25
0
        public void CachingAfterGetCache([Object] DiagnosticDataWrapper eventData)
        {
            var context = _localSegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Get Cache End"));
            context.Span.AddLog(LogEvent.Message($"Adnc.Caching get cache succeeded!{Environment.NewLine}" +
                                                 $"--> Message Id: { eventData.OperationId }"));

            _tracingContext.Release(context);
        }
예제 #26
0
        public void AfterPublishStore([Object] CapEventDataPubStore eventData)
        {
            var context = _localSegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Event Persistence"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence succeeded!"));
            context.Span.AddLog(LogEvent.Message("Spend Time: " + eventData.ElapsedTimeMs + "ms"));

            _tracingContext.Release(context);
        }
        public void AfterPublishStore([Object] CapEventDataPubStore eventData)
        {
            var context = _localSegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Event Persistence End"));
            context.Span.AddLog(LogEvent.Message($"CAP message persistence succeeded!{Environment.NewLine}" +
                                                 $"--> Spend Time: { eventData.ElapsedTimeMs }ms.{Environment.NewLine}" +
                                                 $"--> Message Id: { eventData.Message.GetId() } , Name: { eventData.Operation} "));

            _tracingContext.Release(context);
        }
예제 #28
0
        public void AfterServiceInvoke([Object] ServiceInvokeAfterEventData eventData)
        {
            var context = _entrySegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }
            context.Span.AddTag("hasError", eventData.ResultData.HasError);

            var           logEvent = $"end";
            StringBuilder sbLog    = new StringBuilder();

            sbLog.AppendLine($"HasError: {eventData.ResultData.HasError}");
            if (eventData.ResultData.HasError)
            {
                sbLog.AppendLine($"ErrorCode: {eventData.ResultData.ErrorCode}");
                sbLog.AppendLine($"ErrorMsg: {eventData.ResultData.ErrorMsg}");
                sbLog.AppendLine($"Exception: {eventData.ResultData.ExceptionMessage}");
            }
            context.Span.AddLog(LogEvent.Event(logEvent), LogEvent.Message(sbLog.ToString()));
            _tracingContext.Release(context);
        }
예제 #29
0
        public void EndRequest([Property] HttpContext httpContext)
        {
            var context = _segmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            foreach (var handler in _diagnosticHandlers)
            {
                if (handler.OnlyMatch(httpContext))
                {
                    handler.EndRequest(context, httpContext);
                    break;
                }
            }

            _tracingContext.Release(context);
        }
        public void HttpResponse([Property(Name = "Response")] HttpResponseMessage response)
        {
            var context = _contextAccessor.Context;

            if (context == null)
            {
                return;
            }

            if (response != null)
            {
                var statusCode = (int)response.StatusCode;
                if (statusCode >= 400)
                {
                    context.Span.ErrorOccurred();
                }

                context.Span.AddTag(Tags.STATUS_CODE, statusCode);
            }

            _tracingContext.Release(context);
        }