diff --git a/framework/src/Silky.Core/Logging/LoggerExtensions.cs b/framework/src/Silky.Core/Logging/LoggerExtensions.cs index 7dcbb4741..e49974a8e 100644 --- a/framework/src/Silky.Core/Logging/LoggerExtensions.cs +++ b/framework/src/Silky.Core/Logging/LoggerExtensions.cs @@ -5,7 +5,6 @@ using Silky.Core.Extensions.Collections.Generic; using Microsoft.Extensions.Logging; using Silky.Core.Exceptions; -using Silky.Core.MiniProfiler; namespace Silky.Core.Logging { @@ -71,21 +70,6 @@ public static void LogException(this ILogger logger, Exception ex, LogLevel? lev LogData(logger, ex, selectedLevel); } - public static void LogWithMiniProfiler(this ILogger logger, string category, string state, - string message, bool isError = false, LogLevel? level = null, params object[] args) - { - level ??= isError ? LogLevel.Error : LogLevel.Debug; - logger.LogWithLevel(level.Value, message, args); - if (args != null && args.Any()) - { - MiniProfilerHelper.Print(category, state, string.Format(message, args), isError); - } - else - { - MiniProfilerHelper.Print(category, state, message, isError); - } - } - private static void LogKnownProperties(ILogger logger, Exception exception, LogLevel logLevel) { if (exception is IHasErrorCode exceptionWithErrorCode) diff --git a/framework/src/Silky.Core/Silky.Core.csproj b/framework/src/Silky.Core/Silky.Core.csproj index c9e0a8165..c9bf61af3 100644 --- a/framework/src/Silky.Core/Silky.Core.csproj +++ b/framework/src/Silky.Core/Silky.Core.csproj @@ -10,7 +10,6 @@ - diff --git a/framework/src/Silky.Http.Core/Handler/DefaultHttpMessageReceivedHandler.cs b/framework/src/Silky.Http.Core/Handler/DefaultHttpMessageReceivedHandler.cs index 962d8de9d..63f94f31d 100644 --- a/framework/src/Silky.Http.Core/Handler/DefaultHttpMessageReceivedHandler.cs +++ b/framework/src/Silky.Http.Core/Handler/DefaultHttpMessageReceivedHandler.cs @@ -4,13 +4,13 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Silky.Core; using Silky.Core.Exceptions; using Silky.Core.Extensions; using Silky.Core.Logging; -using Silky.Core.MiniProfiler; using Silky.Core.Runtime.Rpc; using Silky.Core.Serialization; using Silky.Http.Core.Configuration; @@ -61,9 +61,8 @@ protected override async Task HandleCallAsyncCore(HttpContext httpContext, if (!serviceKey.IsNullOrEmpty()) { RpcContext.Context.SetServiceKey(serviceKey); - Logger.LogWithMiniProfiler(MiniProfileConstant.Route.Name, - MiniProfileConstant.Route.State.FindServiceKey, - $"serviceKey => {serviceKey}"); + Logger.LogInformation( + $"serviceKey => {serviceKey} for serviceEntryId {serviceEntry.Id}"); } var rpcConnection = RpcContext.Context.Connection; @@ -162,9 +161,8 @@ protected override async Task HandleCallAsyncCore(HttpContext httpContext, if (!serviceKey.IsNullOrEmpty()) { RpcContext.Context.SetServiceKey(serviceKey); - Logger.LogWithMiniProfiler(MiniProfileConstant.Route.Name, - MiniProfileConstant.Route.State.FindServiceKey, - $"serviceKey => {serviceKey}"); + Logger.LogInformation( + $"serviceKey => {serviceKey} for serviceEntryId {serviceEntryDescriptor.Id}"); } var clientRpcEndpoint = RpcContext.Context.Connection.ClientHost; diff --git a/framework/src/Silky.Http.Core/HttpContextServerCallContext.cs b/framework/src/Silky.Http.Core/HttpContextServerCallContext.cs index 79072bc75..61ea4ae13 100644 --- a/framework/src/Silky.Http.Core/HttpContextServerCallContext.cs +++ b/framework/src/Silky.Http.Core/HttpContextServerCallContext.cs @@ -9,16 +9,12 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; using Silky.Core; using Silky.Core.Exceptions; using Silky.Core.Extensions; -using Silky.Core.Logging; -using Silky.Core.MiniProfiler; using Silky.Core.Runtime.Rpc; using Silky.Core.Serialization; using Silky.Http.Core.Configuration; -using Silky.Rpc.Configuration; using Silky.Rpc.Extensions; using Silky.Rpc.Runtime.Server; using Silky.Rpc.Security; @@ -79,9 +75,8 @@ public void Initialize(ISystemClock? clock = null) SilkyRpcEventSource.Log.CallStart(ServiceEntryDescriptor.Id); var path = HttpContext.Request.Path; var method = HttpContext.Request.Method.ToEnum(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Route.Name, - MiniProfileConstant.Route.State.FindServiceEntry, - $"Find the ServiceEntryDescriptor {ServiceEntryDescriptor.Id} through {path}-{method}"); + Logger.LogInformation( + $"Find the ServiceEntryDescriptor {ServiceEntryDescriptor.Id} through {method} - {path}"); HttpContext.SetUserClaims(); HttpContext.SetHttpHandleAddressInfo(); RpcContext.Context.SetInvokeAttachment(AttachmentKeys.Path, path.ToString()); diff --git a/framework/src/Silky.Core/MiniProfiler/MiniProfileConstant.cs b/framework/src/Silky.Http.MiniProfiler/MiniProfileConstant.cs similarity index 98% rename from framework/src/Silky.Core/MiniProfiler/MiniProfileConstant.cs rename to framework/src/Silky.Http.MiniProfiler/MiniProfileConstant.cs index 028309d1d..dbbe5069e 100644 --- a/framework/src/Silky.Core/MiniProfiler/MiniProfileConstant.cs +++ b/framework/src/Silky.Http.MiniProfiler/MiniProfileConstant.cs @@ -1,4 +1,4 @@ -namespace Silky.Core.MiniProfiler +namespace Silky.Http.MiniProfiler { public static class MiniProfileConstant { diff --git a/framework/src/Silky.Core/MiniProfiler/MiniProfilerHelper.cs b/framework/src/Silky.Http.MiniProfiler/MiniProfilerHelper.cs similarity index 96% rename from framework/src/Silky.Core/MiniProfiler/MiniProfilerHelper.cs rename to framework/src/Silky.Http.MiniProfiler/MiniProfilerHelper.cs index ff74a266a..8007da60c 100644 --- a/framework/src/Silky.Core/MiniProfiler/MiniProfilerHelper.cs +++ b/framework/src/Silky.Http.MiniProfiler/MiniProfilerHelper.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; +using Silky.Core; using Silky.Core.Extensions; using StackExchange.Profiling; -namespace Silky.Core.MiniProfiler +namespace Silky.Http.MiniProfiler { public static class MiniProfilerHelper { diff --git a/framework/src/Silky.Http.MiniProfiler/MiniProfilerServiceCollectionExtensions.cs b/framework/src/Silky.Http.MiniProfiler/MiniProfilerServiceCollectionExtensions.cs index 8605c0c29..4d7d2d554 100644 --- a/framework/src/Silky.Http.MiniProfiler/MiniProfilerServiceCollectionExtensions.cs +++ b/framework/src/Silky.Http.MiniProfiler/MiniProfilerServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -using Silky.Core.MiniProfiler; +using Silky.Http.MiniProfiler; namespace Microsoft.Extensions.DependencyInjection { diff --git a/framework/src/Silky.Rpc.CachingInterceptor/Interceptor/CachingInterceptor.cs b/framework/src/Silky.Rpc.CachingInterceptor/Interceptor/CachingInterceptor.cs index 94f346534..fcdbc647f 100644 --- a/framework/src/Silky.Rpc.CachingInterceptor/Interceptor/CachingInterceptor.cs +++ b/framework/src/Silky.Rpc.CachingInterceptor/Interceptor/CachingInterceptor.cs @@ -5,8 +5,6 @@ using Silky.Core.DependencyInjection; using Silky.Core.DynamicProxy; using Silky.Core.Extensions; -using Silky.Core.Logging; -using Silky.Core.MiniProfiler; using Silky.Rpc.Extensions; using Silky.Rpc.Runtime.Server; @@ -170,9 +168,8 @@ async Task GetResultFirstFromCache(string cacheName, string cacheKey, Se { if (serviceEntry.IsTransactionServiceEntry()) { - Logger.LogWithMiniProfiler(MiniProfileConstant.Caching.Name, - MiniProfileConstant.Caching.State.GetCaching, - $"Cache interception is invalid in distributed transaction processing"); + Logger.LogDebug( + $"Cache interception is invalid in distributed transaction processing for the serviceEntry method {serviceEntry.GetCacheName()}"); await invocation.ProceedAsync(); proceed = ProceedType.ForExec; @@ -182,8 +179,7 @@ async Task GetResultFirstFromCache(string cacheName, string cacheKey, Se _distributedCache.SetIgnoreMultiTenancy(getCachingInterceptProvider.IgnoreMultiTenancy); var getCacheKeyInfo = CacheKeyHelper.GetCachingInterceptKey(serviceEntry, parameters, serviceEntry.GetGetCachingInterceptProvider(), serviceKey); - Logger.LogWithMiniProfiler(MiniProfileConstant.Caching.Name, - MiniProfileConstant.Caching.State.GetCaching, + Logger.LogDebug( $"Ready to get data from the cache service:[cacheName=>{serviceEntry.GetCacheName()};cacheKey=>{getCacheKeyInfo.Item1}]"); if (getCacheKeyInfo.Item2) { diff --git a/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteCaller.cs b/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteCaller.cs index 2e576a114..4e6e0ebda 100644 --- a/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteCaller.cs +++ b/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteCaller.cs @@ -7,7 +7,6 @@ using Silky.Core; using Silky.Core.Exceptions; using Silky.Core.Logging; -using Silky.Core.MiniProfiler; using Silky.Core.Runtime.Rpc; using Silky.Core.Serialization; using Silky.Core.Utils; @@ -15,7 +14,6 @@ using Silky.Rpc.Endpoint.Selector; using Silky.Rpc.Extensions; using Silky.Rpc.Runtime.Server; -using Silky.Rpc.Security; using Silky.Rpc.Transport; using Silky.Rpc.Transport.Messages; @@ -51,7 +49,7 @@ public DefaultRemoteCaller(IServerManager serverManager, { var sp = Stopwatch.StartNew(); var messageId = GuidGenerator.CreateGuidStrWithNoUnderline(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.Start, + Logger.LogDebug( "The rpc request call start{0} serviceEntryId:[{1}]", args: new[] { Environment.NewLine, remoteInvokeMessage.ServiceEntryId }); ClientInvokeInfo? clientInvokeInfo = null; @@ -83,8 +81,6 @@ public DefaultRemoteCaller(IServerManager serverManager, catch (Exception ex) { sp.Stop(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.Fail, - $"The rpc request call failed"); _clientInvokeDiagnosticListener.TracingError(tracingTimestamp, messageId, remoteInvokeMessage.ServiceEntryId, ex.GetExceptionStatusCode(), ex); @@ -105,9 +101,6 @@ public DefaultRemoteCaller(IServerManager serverManager, sp.Stop(); invokeMonitor?.ExecSuccess((remoteInvokeMessage.ServiceEntryId, selectedRpcEndpoint), sp.Elapsed.TotalMilliseconds, clientInvokeInfo); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, - MiniProfileConstant.Rpc.State.Success, - $"The rpc request call succeeded"); var invokeResult = remoteInvoker.RemoteResult; _clientInvokeDiagnosticListener.TracingAfter(tracingTimestamp, messageId, remoteInvokeMessage.ServiceEntryId, invokeResult); @@ -117,7 +110,7 @@ public DefaultRemoteCaller(IServerManager serverManager, private ISilkyEndpoint[] FindRpcEndpoint(RemoteInvokeMessage remoteInvokeMessage) { var rpcEndpoints = _serverManager.GetRpcEndpoints(remoteInvokeMessage.ServiceId, ServiceProtocol.Rpc); - if (rpcEndpoints == null || !rpcEndpoints.Any()) + if (rpcEndpoints == null || !rpcEndpoints.Any()) { throw new NotFindServiceRouteException( $"The service routing could not be found via [{remoteInvokeMessage.ServiceId}]"); @@ -154,8 +147,7 @@ private ISilkyEndpoint SelectedRpcEndpoint(ISilkyEndpoint[] rpcEndpoints, ShuntS hashKey)); } - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, - MiniProfileConstant.Rpc.State.SelectedAddress, + Logger.LogDebug( "There are currently available service provider addresses:{0}{1}" + "The selected service provider rpcEndpoint is:[{2}]", args: new[] diff --git a/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteExecutor.cs b/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteExecutor.cs index a49efdcc9..a9adbd041 100644 --- a/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteExecutor.cs +++ b/framework/src/Silky.Rpc/Runtime/Client/DefaultRemoteExecutor.cs @@ -1,12 +1,9 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Polly; using Silky.Core.Extensions.Collections.Generic; using Silky.Core.Logging; -using Silky.Core.MiniProfiler; using Silky.Core.Runtime.Rpc; using Silky.Rpc.Endpoint.Selector; using Silky.Rpc.Runtime.Server; @@ -45,8 +42,8 @@ public async Task Execute(ServiceEntry serviceEntry, object[] parameters if (serviceEntry.GovernanceOptions.ShuntStrategy == ShuntStrategy.HashAlgorithm) { hashKey = GetHashKeyValue(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.HashKey, - $"The value of hashkey corresponding to this rpc request is:[{hashKey}]"); + Logger.LogDebug( + $"The value of hashkey corresponding to this rpc request is:[{hashKey}] for serviceEntryId:[{serviceEntry.Id}]"); } var policy = _invokePolicyBuilder.Build(serviceEntry.Id, parameters); @@ -71,8 +68,8 @@ public async Task Execute(ServiceEntryDescriptor serviceEntryDescriptor, if (serviceEntryDescriptor.GovernanceOptions.ShuntStrategy == ShuntStrategy.HashAlgorithm) { hashKey = GetHashKeyValue(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.HashKey, - $"The value of hashkey corresponding to this rpc request is:[{hashKey}]"); + Logger.LogDebug( + $"The value of hashkey corresponding to this rpc request is:[{hashKey}] for serviceEntryId:[{serviceEntryDescriptor.Id}]"); } var policy = _invokePolicyBuilder.Build(serviceEntryDescriptor.Id); @@ -98,8 +95,8 @@ public async Task Execute(ServiceEntryDescriptor serviceEntryDescriptor, if (serviceEntryDescriptor.GovernanceOptions.ShuntStrategy == ShuntStrategy.HashAlgorithm) { hashKey = GetHashKeyValue(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.HashKey, - $"The value of hashkey corresponding to this rpc request is:[{hashKey}]"); + Logger.LogDebug( + $"The value of hashkey corresponding to this rpc request is:[{hashKey}] for serviceEntryId:[{serviceEntryDescriptor.Id}]"); } var policy = _invokePolicyBuilder.Build(serviceEntryDescriptor.Id); @@ -125,8 +122,8 @@ public async Task Execute(ServiceEntryDescriptor serviceEntryDescriptor, if (serviceEntryDescriptor.GovernanceOptions.ShuntStrategy == ShuntStrategy.HashAlgorithm) { hashKey = GetHashKeyValue(); - Logger.LogWithMiniProfiler(MiniProfileConstant.Rpc.Name, MiniProfileConstant.Rpc.State.HashKey, - $"The value of hashkey corresponding to this rpc request is:[{hashKey}]"); + Logger.LogDebug( + $"The value of hashkey corresponding to this rpc request is:[{hashKey}] for serviceEntryId:[{serviceEntryDescriptor.Id}]"); } var policy = _invokePolicyBuilder.Build(serviceEntryDescriptor.Id); diff --git a/framework/src/Silky.SkyApm.Diagnostics.Http/Utils/PathUtils.cs b/framework/src/Silky.SkyApm.Diagnostics.Http/Utils/PathUtils.cs index 06a365223..04540c2a1 100644 --- a/framework/src/Silky.SkyApm.Diagnostics.Http/Utils/PathUtils.cs +++ b/framework/src/Silky.SkyApm.Diagnostics.Http/Utils/PathUtils.cs @@ -1,5 +1,4 @@ using System.Linq; -using Silky.Core.MiniProfiler; namespace Silky.SkyApm.Diagnostics.Rpc.Http.Utils { @@ -14,7 +13,7 @@ public static class PathUtils ".png", ".gif", ".html", - MiniProfileConstant.MiniProfilerRouteBasePath + "/index-mini-profiler" }; public static bool IsWebApiPath(string path)