Spyglass.AspNetCore.EntityFrameworkCore
0.2.1
dotnet add package Spyglass.AspNetCore.EntityFrameworkCore --version 0.2.1
NuGet\Install-Package Spyglass.AspNetCore.EntityFrameworkCore -Version 0.2.1
<PackageReference Include="Spyglass.AspNetCore.EntityFrameworkCore" Version="0.2.1" />
<PackageVersion Include="Spyglass.AspNetCore.EntityFrameworkCore" Version="0.2.1" />
<PackageReference Include="Spyglass.AspNetCore.EntityFrameworkCore" />
paket add Spyglass.AspNetCore.EntityFrameworkCore --version 0.2.1
#r "nuget: Spyglass.AspNetCore.EntityFrameworkCore, 0.2.1"
#:package Spyglass.AspNetCore.EntityFrameworkCore@0.2.1
#addin nuget:?package=Spyglass.AspNetCore.EntityFrameworkCore&version=0.2.1
#tool nuget:?package=Spyglass.AspNetCore.EntityFrameworkCore&version=0.2.1
Spyglass.AspNetCore.EntityFrameworkCore
EF Core integration for the Spyglass observability dashboard. Captures slow queries and failed queries via a DbCommandInterceptor and streams them live to a dedicated Queries tab.
Installation
dotnet add package Spyglass.AspNetCore.EntityFrameworkCore
Requires Spyglass.AspNetCore.
Setup
Call .AddEntityFrameworkCore() on the Spyglass builder, then add the interceptor to each DbContext:
builder.Services.AddSpyglass()
.AddEntityFrameworkCore();
builder.Services.AddDbContext<AppDbContext>((sp, options) =>
{
options.UseNpgsql(connectionString);
options.AddSpyglassInterceptor(sp);
});
AddSpyglassInterceptor is a convenience extension on DbContextOptionsBuilder. You can also register the interceptor directly:
options.AddInterceptors(sp.GetRequiredService<SpyglassQueryInterceptor>());
Configuration
Pass a configuration delegate to adjust capture behaviour:
builder.Services.AddSpyglass()
.AddEntityFrameworkCore(options =>
{
options.SlowQueryThresholdMs = 250; // default: 100
options.MaxCommandTextLength = 5_000; // default: 10 000
});
| Option | Default | Description |
|---|---|---|
SlowQueryThresholdMs |
100 |
Queries at or above this threshold (ms) are captured. Set to 0 to capture all queries. |
MaxCommandTextLength |
10000 |
Maximum characters captured from CommandText. Longer SQL is truncated to avoid memory bloat. |
What it shows
The Queries tab streams captured entries live and retains up to 500 in memory. Each entry shows:
- Time — when the command completed
- DbContext — the
DbContextsubclass that issued the command - Elapsed — execution time; colour-coded neutral / amber (1–5× threshold) / red (5×+)
- Status — OK or Error
- Query — a truncated preview of the SQL
Click any row to expand a detail panel with the full SQL and, for errors, the exception message.
The page includes an Errors only toggle, a SQL search filter, sortable columns, and auto-scroll.
All queries are captured regardless of the EF Core provider — the interceptor hooks at the DbCommand level.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.16)
- Spyglass.AspNetCore (>= 0.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See CHANGELOG.md at https://github.com/jhuessen/spyglass/blob/main/CHANGELOG.md