Browse Source

More performance tracking.

pull/334/head
Sebastian Stehle 7 years ago
parent
commit
11cfa52897
  1. 1
      src/Squidex/Config/Web/WebServices.cs
  2. 6
      src/Squidex/Pipeline/ETagExtensions.cs
  3. 32
      src/Squidex/Pipeline/MeasureResultFilter.cs

1
src/Squidex/Config/Web/WebServices.cs

@ -45,6 +45,7 @@ namespace Squidex.Config.Web
{
options.Filters.Add<ETagFilter>();
options.Filters.Add<AppResolver>();
options.Filters.Add<MeasureResultFilter>();
}).AddMySerializers();
services.AddCors();

6
src/Squidex/Pipeline/ETagExtensions.cs

@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Log;
namespace Squidex.Pipeline
{
@ -15,7 +16,10 @@ namespace Squidex.Pipeline
{
public static string ToManyEtag<T>(this IEnumerable<T> items, long total = 0) where T : IGenerateEtag
{
return $"{total}_{string.Join(";", items.Select(x => $"{x.Id}{x.Version}"))}".Sha256Base64();
using (Profiler.Trace("CalculateEtag"))
{
return $"{total}_{string.Join(";", items.Select(x => $"{x.Id}{x.Version}"))}".Sha256Base64();
}
}
public static string ToSurrogateKeys<T>(this IEnumerable<T> items) where T : IGenerateEtag

32
src/Squidex/Pipeline/MeasureResultFilter.cs

@ -0,0 +1,32 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
using Squidex.Infrastructure.Log;
namespace Squidex.Pipeline
{
public sealed class MeasureResultFilter : IAsyncResultFilter, IAsyncActionFilter
{
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
using (Profiler.Trace("ExecuteAction"))
{
await next();
}
}
public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
using (Profiler.Trace("ExecuteResult"))
{
await next();
}
}
}
}
Loading…
Cancel
Save