Skip to content

Commit

Permalink
取消404找不到路径的埋点,避免TraceItem过多
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Oct 7, 2024
1 parent 4305f19 commit 90c0223
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CubeDemoNC/CubeDemoNC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.8" />
<PackageReference Include="NewLife.Redis.Extensions" Version="5.7.2024.801" />
<PackageReference Include="NewLife.Redis.Extensions" Version="6.0.2024.1006" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.1.2024.1004" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion CubeSSO/CubeSSO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1001" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1006-beta1717" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.1.2024.1004" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion NewLife.Cube/NewLife.Cube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<Compile Include="..\NewLife.CubeNC\WebMiddleware\TracerMiddleware.cs" Link="WebMiddleware\TracerMiddleware.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1001" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1006-beta1717" />
<PackageReference Include="NewLife.IP" Version="2.2.2024.902" />
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1004" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1005" />
Expand Down
2 changes: 1 addition & 1 deletion NewLife.CubeNC/NewLife.CubeNC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1001" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1006-beta1717" />
<PackageReference Include="NewLife.IP" Version="2.2.2024.902" />
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1004" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1005" />
Expand Down
12 changes: 10 additions & 2 deletions NewLife.CubeNC/WebMiddleware/TracerMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using NewLife.Collections;
using NewLife.Log;
using NewLife.Web;
using HttpContext = Microsoft.AspNetCore.Http.HttpContext;
Expand Down Expand Up @@ -46,10 +47,11 @@ public async Task Invoke(HttpContext ctx)
{
req.EnableBuffering();

var buf = new Byte[1024];
var buf = Pool.Shared.Rent(1024);
var count = await req.Body.ReadAsync(buf, 0, buf.Length);
span.AppendTag("\r\n<=\r\n" + buf.ToStr(null, 0, count));
req.Body.Position = 0;
Pool.Shared.Return(buf);
flag = true;
}

Expand Down Expand Up @@ -95,11 +97,12 @@ public async Task Invoke(HttpContext ctx)
res.ContentType != null &&
res.ContentType.StartsWithIgnoreCase(TagTypes))
{
var buf = new Byte[1024];
var buf = Pool.Shared.Rent(1024);
var p = res.Body.Position;
var count = await res.Body.ReadAsync(buf, 0, buf.Length);
span.AppendTag("\r\n=>\r\n" + buf.ToStr(null, 0, count));
res.Body.Position = p;
Pool.Shared.Return(buf);
flag = true;
}

Expand All @@ -117,6 +120,11 @@ public async Task Invoke(HttpContext ctx)
}
}
}
else if (code == 404)
{
// 取消404找不到路径的埋点,避免TraceItem过多
span?.Abandon();
}
}
}
catch (Exception ex)
Expand Down

0 comments on commit 90c0223

Please sign in to comment.