Skip to content

Commit

Permalink
优化异常埋点记录;AppTracer.TraceItems 有内存泄漏风险,需要解耦为ICache,特别是web站点被扫描时,可能单个应用…
Browse files Browse the repository at this point in the history
…产生10万个TraceItem。
  • Loading branch information
猿人易 committed Sep 20, 2024
1 parent ff0967e commit 2aec4f7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Stardust.Server/Controllers/TraceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void ProcessData(AppTracer app, TraceModel model, Int32 nodeId, String i
try
{
// 排除项
var excludes = app.Excludes.Split(",", ";") ?? new String[0];
var excludes = app.Excludes.Split(",", ";") ?? [];
//var timeoutExcludes = app.TimeoutExcludes.Split(",", ";") ?? new String[0];

var now = DateTime.Now;
Expand All @@ -213,13 +213,13 @@ private void ProcessData(AppTracer app, TraceModel model, Int32 nodeId, String i
var rule = TraceRule.Match(item.Name);
if (rule != null && !rule.IsWhite)
{
using var span = _tracer?.NewSpan("trace:BlackList", new { item.Name, rule.Rule });
using var span = _tracer?.NewSpan("trace:BlackList", new { item.Name, rule.Rule, ip });
continue;
}

if (excludes != null && excludes.Any(e => e.IsMatch(item.Name, StringComparison.OrdinalIgnoreCase)))
{
using var span = _tracer?.NewSpan("trace:Exclude", item.Name);
using var span = _tracer?.NewSpan("trace:Exclude", new { item.Name, ip });
continue;
}
//if (item.Name.EndsWithIgnoreCase("/Trace/Report")) continue;
Expand All @@ -228,14 +228,14 @@ private void ProcessData(AppTracer app, TraceModel model, Int32 nodeId, String i
var timestamp = item.StartTime.ToDateTime().ToLocalTime();
if (timestamp < startTime || timestamp > endTime)
{
using var span = _tracer?.NewSpan("trace:ErrorTime", $"{item.Name}-{timestamp.ToFullString()}");
using var span = _tracer?.NewSpan("trace:ErrorTime", new { item.Name, timestamp, ip });
continue;
}

// 拒收超长项
if (item.Name.Length > TraceData._.Name.Length)
{
using var span = _tracer?.NewSpan("trace:LongName", item.Name);
using var span = _tracer?.NewSpan("trace:LongName", new { item.Name, ip });
continue;
}

Expand Down

0 comments on commit 2aec4f7

Please sign in to comment.