Reputation: 49
I have integrated MiniProfiler v4.2.22 in my Asp.Net Core application.
Its is working as expected when using In-Memory database, but when i change the storage option to PostgreSQL or SQL Server, no data is coming in the results.
Code Used -
services.AddMiniProfiler(options =>
{
options.UserIdProvider = (request) =>
{
var id = request.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? request.HttpContext.User.FindFirst("sub")?.Value;
return id;
};
options.RouteBasePath = "/profiler";
options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft;
options.PopupShowTimeWithChildren = true;
if (!string.IsNullOrEmpty(miniProfilerOptions?.PostgreSqlStorage?.ConectionString))
{
var storageOpt = miniProfilerOptions.PostgreSqlStorage;
var storage = new PostgreSqlStorage(storageOpt.ConectionString, storageOpt.ProfilersTable, storageOpt.TimingsTable, storageOpt.ClientTimingsTable);
_ = storage.TableCreationScripts;
options.Storage = storage;
}
options.ShouldProfile = (request) =>
{
if (request.Path.StartsWithSegments("/healthcheck"))
{
return false;
}
return true;
};
})
.AddEntityFramework();
appsettings.json -
"Monitoring": {
"MiniProfiler": {
"IsEnabled": true,
"PostgreSqlStorage": {
"ConectionString": "Server=localhost;Port=5432;Database=MiniProfilerTestDB;User ID=myLogin;Password=Password@1234567890;",
"ProfilersTable": "MiniProfilersTable",
"TimingsTable": "MiniProfilerTimingsTable",
"ClientTimingsTable": "MiniProfilerClientTimingsTable"
},
},
}
Model -
public class MiniProfilerOptions
{
public bool IsEnabled { get; set; }
public PostgreSqlStorageOptions PostgreSqlStorage { get; set; }
}
public class PostgreSqlStorageOptions
{
public string ConectionString { get; set; }
public string ProfilersTable { get; set; }
public string TimingsTable { get; set; }
public string ClientTimingsTable { get; set; }
}
SQL Query to create table -
CREATE TABLE "MiniProfilersTable"
(
RowId serial primary key,
Id uuid not null, -- don't cluster on a guid
RootTimingId uuid null,
Name varchar(200) null,
Started timestamp(3) not null,
DurationMilliseconds decimal(15,1) not null,
"User" varchar(100) null,
HasUserViewed boolean not null,
MachineName varchar(100) null,
CustomLinksJson varchar,
ClientTimingsRedirectCount integer null
);
CREATE UNIQUE INDEX IX_MiniProfilersTable_Id ON "MiniProfilersTable" (Id);
CREATE INDEX IX_MiniProfilersTable_User_HasUserViewed_Includes ON "MiniProfilersTable" ("User", HasUserViewed);
CREATE TABLE "MiniProfilerTimingsTable"
(
RowId serial primary key,
Id uuid not null,
MiniProfilerId uuid not null,
ParentTimingId uuid null,
Name varchar(200) not null,
DurationMilliseconds decimal(15,3) not null,
StartMilliseconds decimal(15,3) not null,
IsRoot boolean not null,
Depth smallint not null,
CustomTimingsJson varchar null
);
CREATE UNIQUE INDEX IX_MiniProfilerTimingsTable_Id ON "MiniProfilerTimingsTable" (Id);
CREATE INDEX IX_MiniProfilerTimingsTable_MiniProfilerId ON "MiniProfilerTimingsTable" (MiniProfilerId);
CREATE TABLE "MiniProfilerClientTimingsTable"
(
RowId serial primary key,
Id uuid not null,
MiniProfilerId uuid not null,
Name varchar(200) not null,
Start decimal(9, 3) not null,
Duration decimal(9, 3) not null
);
CREATE UNIQUE INDEX IX_MiniProfilerClientTimingsTable_Id on "MiniProfilerClientTimingsTable" (Id);
CREATE INDEX IX_MiniProfilerClientTimingsTable_MiniProfilerId on "MiniProfilerClientTimingsTable" (MiniProfilerId);
Am i doing something wrong ? or am i missing anything ?
Github Link - https://github.com/MiniProfiler/dotnet/issues/620
Upvotes: 0
Views: 290