diff --git a/sample/SkyApm.Sample.Backend/appsettings.Development.json b/sample/SkyApm.Sample.Backend/appsettings.Development.json index 19b8c152960166afd84a015bb2092164f46a72bf..26bb0ac7ac67a92522d39be319e95be1b129b1d0 100644 --- a/sample/SkyApm.Sample.Backend/appsettings.Development.json +++ b/sample/SkyApm.Sample.Backend/appsettings.Development.json @@ -3,12 +3,12 @@ "IncludeScopes": false, "Debug": { "LogLevel": { - "Default": "Debug" + "Default": "Warning" } }, "Console": { "LogLevel": { - "Default": "Debug" + "Default": "Warning" } } } diff --git a/sample/SkyApm.Sample.Backend/skyapm.json b/sample/SkyApm.Sample.Backend/skyapm.json index 86f0eb4418c7ee905b6d3424a2447961975ed692..b5d2b9883d3c6a8033c7b1a912dfb993cc9985ac 100644 --- a/sample/SkyApm.Sample.Backend/skyapm.json +++ b/sample/SkyApm.Sample.Backend/skyapm.json @@ -20,8 +20,8 @@ "BatchSize": 3000, "gRPC": { "Servers": "localhost:11800", - "Timeout": 10000, - "ConnectTimeout": 10000, + "Timeout": 100000, + "ConnectTimeout": 100000, "ReportTimeout": 600000 } } diff --git a/src/SkyApm.Core/Diagnostics/PropertyAttribute.cs b/src/SkyApm.Core/Diagnostics/PropertyAttribute.cs index 0a8ab9625deed3c559f4d2438e96f6ceb21f9cdb..05d9c3c68b79220cf03cc4f0d8c750644e27c262 100644 --- a/src/SkyApm.Core/Diagnostics/PropertyAttribute.cs +++ b/src/SkyApm.Core/Diagnostics/PropertyAttribute.cs @@ -16,6 +16,8 @@ * */ +using AspectCore.Extensions.Reflection; + namespace SkyApm.Diagnostics { public class PropertyAttribute : ParameterBinder @@ -30,8 +32,8 @@ namespace SkyApm.Diagnostics } var property = value.GetType().GetProperty(Name); - - return property?.GetValue(value); + + return property?.GetReflector()?.GetValue(value); } } } \ No newline at end of file diff --git a/src/SkyApm.Core/Diagnostics/TracingDiagnosticMethod.cs b/src/SkyApm.Core/Diagnostics/TracingDiagnosticMethod.cs index cd19d72e481d37dfd72873c262b7d66d8e291e31..2c855dd0f930acee90b6f6d91d952d8361600cfb 100644 --- a/src/SkyApm.Core/Diagnostics/TracingDiagnosticMethod.cs +++ b/src/SkyApm.Core/Diagnostics/TracingDiagnosticMethod.cs @@ -19,21 +19,22 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using AspectCore.Extensions.Reflection; namespace SkyApm.Diagnostics { internal class TracingDiagnosticMethod { - private readonly MethodInfo _method; private readonly ITracingDiagnosticProcessor _tracingDiagnosticProcessor; private readonly string _diagnosticName; private readonly IParameterResolver[] _parameterResolvers; + private readonly MethodReflector _reflector; public TracingDiagnosticMethod(ITracingDiagnosticProcessor tracingDiagnosticProcessor, MethodInfo method, string diagnosticName) { _tracingDiagnosticProcessor = tracingDiagnosticProcessor; - _method = method; + _reflector = method.GetReflector(); _diagnosticName = diagnosticName; _parameterResolvers = GetParameterResolvers(method).ToArray(); } @@ -51,7 +52,7 @@ namespace SkyApm.Diagnostics args[i] = _parameterResolvers[i].Resolve(value); } - _method.Invoke(_tracingDiagnosticProcessor, args); + _reflector.Invoke(_tracingDiagnosticProcessor, args); } private static IEnumerable GetParameterResolvers(MethodInfo methodInfo) diff --git a/src/SkyApm.Core/SkyApm.Core.csproj b/src/SkyApm.Core/SkyApm.Core.csproj index 457c32c926ea57105d5337b0450ee3c2655113f8..2f5384842b70d4103815d735d62072a9059b7c90 100644 --- a/src/SkyApm.Core/SkyApm.Core.csproj +++ b/src/SkyApm.Core/SkyApm.Core.csproj @@ -12,6 +12,7 @@ netstandard2.0 + diff --git a/src/SkyApm.Core/Transport/AsyncQueueSegmentDispatcher.cs b/src/SkyApm.Core/Transport/AsyncQueueSegmentDispatcher.cs index c8f2062affa7ffa124942a969918279ad018325c..462808b49a7451b7d4669c822c036b35b2c468fe 100644 --- a/src/SkyApm.Core/Transport/AsyncQueueSegmentDispatcher.cs +++ b/src/SkyApm.Core/Transport/AsyncQueueSegmentDispatcher.cs @@ -35,6 +35,7 @@ namespace SkyApm.Transport private readonly ConcurrentQueue _segmentQueue; private readonly IRuntimeEnvironment _runtimeEnvironment; private readonly CancellationTokenSource _cancellation; + private int _offset; public AsyncQueueSegmentDispatcher(IConfigAccessor configAccessor, ISegmentReporter segmentReporter, IRuntimeEnvironment runtimeEnvironment, @@ -55,7 +56,7 @@ namespace SkyApm.Transport return false; // todo performance optimization for ConcurrentQueue - if (_config.QueueSize < _segmentQueue.Count || _cancellation.IsCancellationRequested) + if (_config.QueueSize < _offset || _cancellation.IsCancellationRequested) return false; var segment = _segmentContextMapper.Map(segmentContext); @@ -65,6 +66,8 @@ namespace SkyApm.Transport _segmentQueue.Enqueue(segment); + Interlocked.Increment(ref _offset); + _logger.Debug($"Dispatch trace segment. [SegmentId]={segmentContext.SegmentId}."); return true; } @@ -80,11 +83,15 @@ namespace SkyApm.Transport while (index++ < limit && _segmentQueue.TryDequeue(out var request)) { segments.Add(request); + Interlocked.Decrement(ref _offset); } // send async if (segments.Count > 0) _segmentReporter.ReportAsync(segments, token); + + Interlocked.Exchange(ref _offset, _segmentQueue.Count); + return Task.CompletedTask; }