Exemplo n.º 1
0
        public void Handle(ITracingContext tracingContext, HttpRequestMessage request)
        {
            var Partial = tracingContext.CreateExitPartialContext(request.RequestUri.ToString());

            Partial.Context.Component = "HttpClient";
            Partial.Context.LayerType = ChannelLayerType.HTTP;
            Partial.Context.Add("Method", request.Method.ToString());
            Partial.Context.Add("URL", request.RequestUri.ToString());
            Partial.Context.Add("Path", $"{request.RequestUri.Host}:{request.RequestUri.Port}");
            Partial.Context.Add("Router", request.RequestUri.Host);
        }
        public void BeforeExecuteCommand([Property(Name = "Command")] SqlCommand sqlCommand)
        {
            var commandType = $"SqlClient.{sqlCommand.CommandText?.Split(' ')?.FirstOrDefault()}";
            var ExitPartial = TracingContext.CreateExitPartialContext(commandType);

            ExitPartial.Context.Component = "SqlClient";
            ExitPartial.Context.LayerType = ChannelLayerType.DB;
            ExitPartial.Context.Add("DataSource", sqlCommand.Connection.DataSource);
            ExitPartial.Context.Add("Type", sqlCommand.CommandText?.Split(' ')?.FirstOrDefault().GetSqlHandlerType());
            ExitPartial.Context.Add("DbInstance", sqlCommand.Connection.Database);
            ExitPartial.Context.Add("TSQL", sqlCommand.CommandText);
            ExitPartial.Context.Add("SqlParameters", sqlCommand.Parameters.GetSqlParametersSerlized());
        }
        private PartialContext CreateContext(DbCommand Command, string operationName)
        {
            PartialContext Context;

            foreach (var provider in EFCoreDiagnosticHandler)
            {
                if (provider.Match(Command.Connection))
                {
                    Context = TracingContext.CreateExitPartialContext(operationName);
                    Context.Context.Component = "EntityFrameWorkCore.Complate";
                    return(Context);
                }
            }
            Context = TracingContext.CreateLocalPartialContext(operationName);
            Context.Context.Component = "EntityFrameWorkCore";
            return(Context);
        }