public void OnNext(KeyValuePair <string, object> value)
        {
            if (value.Key == "System.Net.Http.HttpRequestOut.Start")
            {
                var activity = System.Diagnostics.Activity.Current;

                var request = value.Value.GetType().GetProperty("Request").GetValue(value.Value) as System.Net.Http.HttpRequestMessage;

                _context.Push(activity?.SpanId.ToHexString(), new Segment {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = request
                });
            }

            if (value.Key == "System.Net.Http.HttpRequestOut.Stop")
            {
                var activity = System.Diagnostics.Activity.Current;

                var response = value.Value.GetType().GetProperty("Response").GetValue(value.Value) as System.Net.Http.HttpResponseMessage;

                _context.Push(activity?.SpanId.ToHexString(), new Segment
                {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = response
                });

                Build(activity?.SpanId.ToHexString());
            }

            _logger.LogInformation(value.Key);
        }
Exemplo n.º 2
0
        public void OnNext(KeyValuePair <string, object> value)
        {
            var activity = System.Diagnostics.Activity.Current;

            if (value.Key == "System.Net.Http.HttpRequestOut.Start")
            {
                var request = value.Value.GetType().GetProperty("Request").GetValue(value.Value) as System.Net.Http.HttpRequestMessage;

                if (!request.Headers.TryGetValues(BasicConfig.ActiveTraceId, out _))
                {
                    var TraceId = activity.GetBaggageItem(BasicConfig.ActiveTraceId);

                    request.Headers.Add(BasicConfig.ActiveTraceId, TraceId);
                }

                return;

                _context.Push(activity?.SpanId.ToHexString(), new Segment
                {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = request
                });
            }

            if (value.Key == "System.Net.Http.HttpRequestOut.Stop")
            {
                return;

                var response = value.Value.GetType().GetProperty("Response").GetValue(value.Value) as System.Net.Http.HttpResponseMessage;

                _context.Push(activity?.SpanId.ToHexString(), new Segment
                {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = response
                });

                Build(activity?.SpanId.ToHexString());
            }
        }
        public void OnNext(KeyValuePair <string, object> value)
        {
            var activity = System.Diagnostics.Activity.Current;

            if (activity == null)
            {
                return;
            }


            if (value.Key == "System.Data.SqlClient.WriteCommandBefore")
            {
                var SqlCommand = value.Value.GetType().GetProperty("Command").GetValue(value.Value) as System.Data.SqlClient.SqlCommand;

                _context.Push(activity?.SpanId.ToHexString(), new Segment
                {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = SqlCommand
                });
            }

            if (value.Key == "System.Data.SqlClient.WriteCommandAfter")
            {
                var SqlCommand = value.Value.GetType().GetProperty("Command").GetValue(value.Value) as System.Data.SqlClient.SqlCommand;

                _context.Push(activity?.SpanId.ToHexString(), new Segment
                {
                    activity   = activity,
                    CreateTime = DateTime.Now,
                    Value      = SqlCommand
                });

                Build(activity.SpanId.ToHexString());
            }

            if (value.Key == "System.Data.SqlClient.WriteCommandError")
            {
            }
        }