Skip to content

Commit

Permalink
Merge pull request #125 from furkandeveloper/develop
Browse files Browse the repository at this point in the history
Feature/change request value
  • Loading branch information
furkandeveloper authored Oct 2, 2021
2 parents 95d6a4f + 019f43d commit f710bef
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 76 deletions.
12 changes: 4 additions & 8 deletions common.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<Project>
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<Version>2.0.0</Version>
<TargetFrameworks>net5.0</TargetFrameworks>
<Version>2.1.0</Version>
<LangVersion>latest</LangVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/furkandeveloper/EasyProfiler</RepositoryUrl>
<Authors>furkandeveloper</Authors>
<Description>This repo, provides query profiler for .Net</Description>
<PackageTags>mariadb, profiler, query-profiler,query-analyzer</PackageTags>
<PackageReleaseNotes>
## This release includes breaking changes;

♻ Refactor base scenario.
♻ Add CronJob service for database tracking.
♻ Update Profiler Database schema.
♻ Change Profiler Db Context.
🔥 Removes .Net Core 3.x support
♻ Change request url property set scenario from path value to get endpoint information from all providers
</PackageReleaseNotes>
</PropertyGroup>
</Project>
13 changes: 10 additions & 3 deletions samples/EasyProfiler.Web/Controllers/DefaultController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace EasyProfiler.Web.Controllers
{
/// <summary>
/// Default Controller
/// </summary>
[ApiController]
[Route("[controller]")]
public class DefaultController : ControllerBase
{
private readonly SampleDbContext sampleDbContext;

/// <summary>
/// Ctor
/// </summary>
/// <param name="sampleDbContext">
/// DB Context
/// </param>
public DefaultController(SampleDbContext sampleDbContext)
{
this.sampleDbContext = sampleDbContext;
Expand Down Expand Up @@ -62,7 +69,7 @@ public async Task<IActionResult> GetAllCustomersAsync()
/// <param name="model">
/// Advanced filter model.
/// </param>
/// <param name="easyProfilerService">
/// <param name="baseService">
/// Easy profiler service.
/// </param>
/// <returns>
Expand Down
12 changes: 6 additions & 6 deletions samples/EasyProfiler.Web/EasyProfiler.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>e3b4a23d-9c60-48fb-b05a-3a755149e281</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
Expand All @@ -12,15 +12,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.MarkdownDocumenting" Version="2.1.2" />
<PackageReference Include="AutoFilterer.Swagger" Version="2.2.0" />
<PackageReference Include="AspNetCore.MarkdownDocumenting" Version="2.3.0" />
<PackageReference Include="AutoFilterer.Swagger" Version="2.8.0" />
<!--<PackageReference Include="EasyProfiler.SQLServer" Version="1.0.0" />-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
30 changes: 30 additions & 0 deletions samples/EasyProfiler.Web/SampleDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,46 @@

namespace EasyProfiler.Web
{
/// <summary>
/// Sample Db Context
/// </summary>
public class SampleDbContext : DbContext
{
/// <summary>
/// Ctor
/// </summary>
/// <param name="options">
/// DbContextOptions
/// </param>
public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options)
{
}

/// <summary>
/// Ctor
/// </summary>
protected SampleDbContext()
{
}
/// <summary>
/// Customer Table
/// </summary>
public virtual DbSet<Customer> Customers { get; set; }

/// <summary>
/// OnModelCreating
/// </summary>
/// <param name="modelBuilder">
/// Summary:
/// Provides a simple API surface for configuring a Microsoft.EntityFrameworkCore.Metadata.IMutableModel
/// that defines the shape of your entities, the relationships between them, and
/// how they map to the database.
/// You can use Microsoft.EntityFrameworkCore.ModelBuilder to construct a model for
/// a context by overriding Microsoft.EntityFrameworkCore.DbContext.OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder)
/// on your derived context. Alternatively you can create the model externally and
/// set it on a Microsoft.EntityFrameworkCore.DbContextOptions instance that is passed
/// to the context constructor.
/// </param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>(entity =>
Expand Down
16 changes: 9 additions & 7 deletions samples/EasyProfiler.Web/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
using AutoFilterer.Swagger;
using EasyProfiler.PostgreSQL.Context;
using EasyProfiler.PostgreSQL.Extensions;
using MarkdownDocumenting.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Intrinsics;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace EasyProfiler.Web
{
Expand All @@ -38,6 +32,10 @@ public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
/// <summary>
/// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services"></param>
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
Expand Down Expand Up @@ -91,7 +89,11 @@ public void ConfigureServices(IServiceCollection services)
services.AddDocumentation();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.ApplyEasyProfilerPostgreSQL();
Expand Down
6 changes: 1 addition & 5 deletions src/EasyProfiler.Core/EasyProfiler.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
<PackageId>EasyProfiler.Core</PackageId>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoFilterer" Version="2.6.1" />
<PackageReference Include="AutoFilterer" Version="2.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions src/EasyProfiler.CronJob/EasyProfiler.CronJob.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<Import Project="..\..\common.props" />

<ItemGroup>
<PackageReference Include="Cronos" Version="0.7.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.11" />
<PackageReference Include="Cronos" Version="0.7.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\common.props" />
<PropertyGroup>
<PackageId>EasyProfiler.EntityFrameworkCore</PackageId>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.12" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EasyProfiler.MariaDb/Context/DesignTimeDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ProfilerMariaDbContext CreateDbContext(string[] args)
optionsBuilder.UseMySql("----");
#elif NET5_0_OR_GREATER
// TODO: Remove here if not necessary.
optionsBuilder.UseMySql("----", ServerVersion.FromString("10.5.9"));
optionsBuilder.UseMySql("----", ServerVersion.AutoDetect("10.5.9"));
#endif

return new ProfilerMariaDbContext(optionsBuilder.Options);
Expand Down
11 changes: 3 additions & 8 deletions src/EasyProfiler.MariaDb/EasyProfiler.MariaDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
<PackageId>EasyProfiler.MariaDb</PackageId>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EasyProfiler.CronJob\EasyProfiler.CronJob.csproj" />
<ProjectReference Include="..\EasyProfiler.EntityFrameworkCore\EasyProfiler.EntityFrameworkCore.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override InterceptionResult DataReaderDisposing(DbCommand command, DataRe
{
Duration = eventData.Duration.Ticks,
Query = command.CommandText,
RequestUrl = httpContextAccessor?.HttpContext?.Request?.Path.Value,
RequestUrl = httpContextAccessor?.HttpContext?.GetEndpoint()?.DisplayName ?? "Not Http",
QueryType = command.FindQueryType(),
EndDate = DateTime.UtcNow,
StartDate = DateTime.UtcNow - eventData.Duration
Expand Down
2 changes: 1 addition & 1 deletion src/EasyProfiler.Mongo/EasyProfiler.Mongo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.11.5" />
<PackageReference Include="MongoDB.Driver" Version="2.13.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void InitilazeSucceededEvent(this CommandSucceededEvent command, I
Duration = command.Duration.Ticks,
Query = data.ToString(),
QueryType = command.CommandName.FindQueryType(),
RequestUrl = httpContext?.HttpContext?.Request?.Path.Value,
RequestUrl = httpContext?.HttpContext?.GetEndpoint()?.DisplayName ?? "Not Http",
EndDate = DateTime.UtcNow,
StartDate = DateTime.UtcNow - command.Duration
});
Expand Down
12 changes: 2 additions & 10 deletions src/EasyProfiler.PostgreSQL/EasyProfiler.PostgreSQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@
<PackageId>EasyProfiler.PostgreSQL</PackageId>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override InterceptionResult DataReaderDisposing(DbCommand command, DataRe
{
Duration = eventData.Duration.Ticks,
Query = command.CommandText,
RequestUrl = httpContextAccessor?.HttpContext?.Request?.Path.Value,
RequestUrl = httpContextAccessor?.HttpContext?.GetEndpoint()?.DisplayName ?? "Not Http",
QueryType = command.FindQueryType(),
EndDate = DateTime.UtcNow,
StartDate = DateTime.UtcNow - eventData.Duration
Expand Down
12 changes: 2 additions & 10 deletions src/EasyProfiler.SQLServer/EasyProfiler.SQLServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@
<PackageId>EasyProfiler.SQLServer</PackageId>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override InterceptionResult DataReaderDisposing(DbCommand command, DataRe
{
Duration = eventData.Duration.Ticks,
Query = command.CommandText,
RequestUrl = httpContextAccessor?.HttpContext?.Request?.Path.Value,
RequestUrl = httpContextAccessor?.HttpContext?.GetEndpoint()?.DisplayName ?? "Not Http",
QueryType = command.FindQueryType(),
EndDate = DateTime.UtcNow,
StartDate = DateTime.UtcNow - eventData.Duration
Expand Down

0 comments on commit f710bef

Please sign in to comment.