DEV Community

A0mineTV
A0mineTV

Posted on

Laravel Telescope: What It Really Lets You See (and How to Use It Safely)

If you’ve ever asked yourself: “Where did this query come from?”, “Why is this request so slow?”, or “Why did this job fail only once?”, you need more than a simple debugger.

Laravel Telescope is the official package that answers those questions with receipts. It is an observability layer that records exactly what your application is doing—requests, queries, jobs, exceptions—and provides a clean UI to inspect it all in one place.


What Does Telescope Actually Capture?

Think of Telescope as a flight recorder for your app. For every request or background job, it can display:

  • SQL Queries: Full bindings and execution time.
  • HTTP Requests: Headers, payloads, and durations.
  • Exceptions: Full stack traces with user context.
  • Queued Jobs: Payloads, attempts, and failures.
  • And more: Logs, cache operations, mail, and Eloquent model changes.

The "Aha!" Moments: Where Telescope Shines

1. Crushing N+1 Problems

This is often the biggest win. When a page feels sluggish, Telescope shows you every single query, how long it took, and—crucially—which specific line of code triggered it. You can quickly see if you need to add eager loading or cache an expensive aggregate.

When a page feels slow, Telescope shows:

  • every query
  • how long each one took
  • what repeated
  • and which code path triggered it (often the biggest “aha” moment)

Typical fixes after a Telescope session:

  • add eager loading (with())
  • stop calling the same service multiple times per request
  • cache expensive aggregates / lists
  • reduce payload (select only needed columns)

2. The "Time Machine" for Bugs

We’ve all dealt with bugs we can't reproduce locally. Telescope lets you look back in time to see the exact authenticated user, the input payload, and the related logs at the moment an error occurred.

Telescope can tell you:

  • which request triggered the issue
  • the authenticated user
  • the input payload
  • the exception and stack trace
  • related logs around that moment

That’s basically a time machine for your app.

3. Queue Introspection

Telescope allows you to correlate a web request that dispatched a job with the actual execution of that job later, making it easy to track failures and inspect payloads.

If you use queues, Telescope is extremely useful to see:

  • what was dispatched
  • job payload + attempts
  • runtime
  • failures (with trace)

You can also correlate a web request that dispatched a job, then inspect the job execution afterward.


4) Performance diagnosis beyond “just queries”

Many slow requests are not only SQL:

  • heavy serialization / transformers
  • external API calls
  • synchronous file work
  • inefficient loops
  • multiple cache misses

Telescope gives you request duration + event/log context, so you can build a full story of why the request is slow.


Install (quick)

composer require laravel/telescope --dev
php artisan telescope:install
php artisan migrate
Enter fullscreen mode Exit fullscreen mode

Then access it at:

/telescope
Enter fullscreen mode Exit fullscreen mode

Tip: install it in dev + staging first. Then decide what (if anything) you want in production.


The 80/20 Workflow

To get the most out of Telescope without getting lost in data, follow this loop:

  1. Reproduce: Trigger the slow page or failing flow.
  2. Inspect: Check the total request duration and user context in Telescope.
  3. Drill Down: Sort queries by duration and look for duplicates or N+1 patterns.
  4. Fix & Verify: Re-run the request and compare the new query count and duration in the dashboard.

Step 1 — Reproduce the issue

Open Telescope and trigger the slow page or failing flow.

Step 2 — Inspect the request

Look at:

  • total duration
  • request/response info
  • user context

Step 3 — Drill into queries

  • sort by duration
  • look for duplicates
  • search by table name
  • confirm N+1 patterns

Step 4 — Fix + verify

Re-run the request and compare:

  • total request time
  • query count
  • duplicate patterns

Telescope in production: do it safely

Telescope can run in production, but you must treat it as a monitoring tool with cost.

Key risks

  • Performance overhead: recording a lot of entries can be expensive
  • Storage growth: Telescope stores entries in your DB
  • Sensitive data: payloads/headers can contain secrets

Safer approach

  • enable Telescope only for:
    • admins
    • specific IPs
    • or only in staging
  • restrict what gets recorded
  • prune aggressively

Important config knobs

1) Hide sensitive request data

In TelescopeServiceProvider, you can hide values like:

  • Authorization headers
  • cookies
  • passwords
  • tokens

(Exact config depends on your Laravel version, but the intent is always the same: never store secrets.)


2) Filter what gets recorded

The fastest Telescope is the one that records only what you need.

Common strategy:

  • record everything in local dev
  • record only errors/slow requests in staging
  • record minimal data in production (or disable)

3) Prune old entries

Telescope includes pruning support to avoid unlimited DB growth.

Use pruning for environments where Telescope is enabled:

  • keep a few days in staging
  • keep a few hours/day in production (if enabled)
  • or keep only failures

Practical examples: what to look for

Example A — “This endpoint is slow”

In Telescope:

  • open the request entry
  • check query list + durations
  • look for repeated queries
  • confirm if an external API call is blocking

Fix ideas:

  • eager load relationships
  • cache aggregates/lists in Redis (TTL + invalidation)
  • move work to a queue job

Example B — “Users report random 500 errors”

In Telescope:

  • open the exception entry
  • inspect request payload + user
  • cross-check logs in the same timeframe

Fix ideas:

  • add validation for edge cases
  • guard null states
  • add retries around external calls (or isolate in jobs)

Example C — “Job failed but only once”

In Telescope:

  • open the job failure
  • inspect attempts + payload + trace
  • correlate with the request that dispatched it

Fix ideas:

  • make job idempotent
  • add retry/backoff
  • store a dedupe key (Redis lock) for hot jobs

Telescope vs Debugbar: which one?

  • Debugbar is great for quick local profiling in the browser.
  • Telescope is great for full request/job introspection, history, and staging workflows.

In many teams:

  • Debugbar is the “fast local tool”
  • Telescope is the “investigation tool” you use to confirm and explain issues

Final thoughts

Laravel Telescope shines when you want to answer:

  • What happened?
  • Where did it come from?
  • How do we fix it and verify the impact?

If you’re doing performance work, Telescope + a simple “measure → fix → re-measure” loop is one of the highest ROI habits you can build in Laravel.

If you want, I can write a follow-up with a concrete performance case study:

  • detecting N+1
  • fixing it with eager loading
  • then adding Redis caching + invalidation
  • and comparing the before/after in Telescope

Top comments (0)