Skip to content

Telescope ​

Introduction ​

DotBlaze.Telescope is a debug assistant for your local development environment, like Laravel Telescope. It records what your application does and shows it at /telescope: requests, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, events, gate checks, outgoing HTTP requests, console commands, and scheduled tasks.

Entries recorded during the same request, job, or command belong together. Open a request to see its queries, log entries, and the jobs it queued; open a job to see what happened while it ran.

Installation ​

Add the package and run its migration, which creates the telescope_entries table:

bash
dotnet add package DotBlaze.Telescope
bash
dotblaze migrate

Start the app in the Development environment and open /telescope. DotBlaze finds the package by itself; there is nothing to register.

Local-Only Installation ​

Telescope records only in the Development environment by default. Production apps usually do not need it at all; to keep it out of the published app, reference it only in Debug builds:

xml
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
  <PackageReference Include="DotBlaze.Telescope" Version="1.1.0" />
</ItemGroup>

Its migration then only exists in Debug builds too, so run migrate from a Debug build before you first use it.

Keep the version aligned with the application's DotBlaze version. With this conditional reference, wrap Telescope-specific imports and calls in #if DEBUG too, or Release compilation will reference a missing assembly.

Configuration ​

To change Telescope's defaults, add config/Telescope.cs:

csharp
public class TelescopeConfig : ConfigFile
{
    public override object Values() => new
    {
        enabled = IsDevelopment,
        path = "telescope",
        ignore_paths = new[] { "telescope*", "horizon*", "pulse*", "_dotblaze/*", "_live/*", "broadcasting*", "favicon.ico" },
        ignore_commands = new[] { "queue:work", "queue:manager", "schedule:work", "pulse:check", "list", "migrate*", "telescope:*", "tinker" },
        slow_queries = 100,
        log_level = "Information",
        response_size_limit = 64,
        watchers = new
        {
            requests = true,
            commands = true,
            schedule = true,
            jobs = true,
            exceptions = true,
            logs = true,
            queries = true,
            events = true,
            mail = true,
            notifications = true,
            cache = true,
            gates = true,
            http_client = true,
        },
    };
}
KeyDefaultDescription
enabledtrue in Development, otherwise falseRecord entries. The dashboard still shows what was recorded when it is off.
pathtelescopeWhere the dashboard is.
ignore_pathsdashboards and assetsRequests to these paths are not recorded, nor anything that happens during them. A trailing * matches any rest of the path.
ignore_commandslong-running commandsCommands that are not recorded. Jobs that queue:work runs are still recorded.
slow_queries100Queries that take at least this many milliseconds are tagged slow.
log_levelInformationThe lowest level of log entries to record. Log entries of ASP.NET Core and EF Core are recorded from Warning up.
response_size_limit64Response bodies larger than this many kilobytes are not stored.
watchersall trueTurn off what you do not need.

Like Laravel, Telescope collects entries in memory and writes them in the background, about once a second, so recording adds little time to a request. It does record a lot, though: keep it off in production unless you need it there for a short time.

The dashboard has a Pause recording button. Pausing is stored in the cache, so it applies to every process (web, workers) within a few seconds.

Data Pruning ​

Entries pile up quickly. Delete old ones with telescope:prune, for example every day from the scheduler:

csharp
Schedule.Command("telescope:prune --hours=48").Daily();

Without --hours, entries older than 24 hours are deleted. telescope:clear deletes every entry, as does the Clear button on the dashboard.

Dashboard Authorization ​

In the Development environment, everyone can open the dashboard. In every other environment, only users that the viewTelescope gate allows can:

csharp
public override void Boot(WebApplication app)
{
    Gate.Define<User>("viewTelescope", user => user.Email is "taylor@example.com");
}

To decide in another way, use Telescope.Auth, which replaces both the environment check and the gate:

csharp
// In a provider's Boot, after defining viewTelescope:
Telescope.Auth(context => Gate.Allows("viewTelescope"));

Filtering ​

Telescope.Filter decides which entries are recorded. Call it in a provider's Boot method. Return false to drop an entry:

csharp
using DotBlaze.Telescope;

Telescope.Filter(entry => entry.Type != "cache");

Telescope.Filter(entry => entry.Type != "query" || !entry.Content["sql"]!.ToString()!.Contains("sessions"));

An entry has a Type (request, command, schedule, job, exception, log, query, event, mail, notification, cache, gate, or http-client), its Content, its Tags, and the BatchId it shares with the other entries of its request, job, or command.

Tagging ​

Telescope tags entries so you can search for them on the dashboard:

  • requests and gate checks with the user, as Auth:1,
  • mail with its recipients' addresses, and notifications with their notifiable (User:1),
  • slow queries with slow, and failed jobs, requests (5xx), commands, and HTTP calls with failed.

Add your own tags with Telescope.Tag:

csharp
Telescope.Tag(entry => entry.Type == "request" && entry.Content["uri"]?.ToString()?.StartsWith("/api") == true
    ? ["api"]
    : []);

Type a tag in the search box above a list to see only the entries with that tag. Click a tag on an entry to search for it.

Available Watchers ​

WatcherRecords
RequestsMethod, path, controller action, middleware, status, duration, memory, headers, the form or JSON payload, the response (HTML is shown as a preview), and the user.
CommandsThe command, its arguments, exit code, and duration.
ScheduleEach scheduled task that ran, with its cron expression, duration, and error.
JobsEach queued job, updated as it runs: pending, processing, processed, released, or failed, with its data and exception. A job's page also shows what happened while it ran.
ExceptionsReported exceptions (not ignored ones like 404s), with their stack trace and how often the same exception happened.
LogsLog entries at log_level or above, with their structured values.
QueriesEvery SQL command, with its bindings and duration, from models and the query builder.
EventsEvents dispatched with Event.Dispatch, with their data. Model events are left out.
MailSent mail, with a preview of the HTML.
NotificationsEach notification and the channel it went out on.
CacheHits, misses, writes, and removals, with the key and store.
GatesEach ability or policy check, with the user and the result.
HTTP ClientRequests sent with the Http client: the request, the response, and how long it took.

Telescope builds on DotBlaze's framework events, which you can listen to yourself.

Hiding Sensitive Data ​

Telescope masks configured request fields recursively in JSON objects and arrays, and in dotted or bracketed form fields. Field names ignore case and underscores, so PasswordConfirmation matches password_confirmation. Sensitive request headers such as Authorization, Cookie, and CSRF headers are also masked. URLs, responses, SQL bindings, and application logs can still contain sensitive values. Hide additional fields/headers in a provider's Boot method and filter out entries that should not be recorded:

csharp
Telescope.HideRequestParameters("card_number", "cvc");
Telescope.HideRequestHeaders("X-Api-Key");

Complete Example: Protected Debugging Dashboard ​

Install DotBlaze.Telescope in the Blog application, run dotblaze migrate, and add:

csharp
// app/Providers/TelescopeAccessProvider.cs
using Blog.Models;
using DotBlaze;
using DotBlaze.Telescope;
using Microsoft.AspNetCore.Builder;

namespace Blog.Providers;

public class TelescopeAccessProvider : Provider
{
    public override void Boot(WebApplication app)
    {
        Gate.Define<User>("viewTelescope", user => user.Email == "operator@example.test");
        Telescope.Auth(context => Gate.Allows("viewTelescope"));
        Telescope.HideRequestParameters("apiSecret");
        Telescope.HideRequestHeaders("X-Api-Key");
    }
}

Run the local app in Development, register the operator account, sign in, visit /posts, then open /telescope. Expect the request and associated database queries. A different user is denied even in Development because the callback replaces the default environment allowance.

This full source assumes an unconditional package reference. If using the Debug-only reference above, surround its imports and class with #if DEBUG / #endif. Keep production recording disabled unless intentionally configured. Schedule telescope:prune to bound stored records; hiding named request fields does not redact secrets embedded in arbitrary logs or query bindings.

The runnable authorization, recorder, and pruning examples are in DashboardsTest.cs.