Tracking progress | rust-crawler | Spatie       

 SPATIE  

rust-crawler
============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Rust-crawler](https://spatie.be/docs/rust-crawler/v1)  Basic-usage  Tracking progress

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/rust-crawler/v1) 

  Tracking progress    
- [ Introduction ](https://spatie.be/docs/rust-crawler/v1/introduction)
- [ Installation &amp; setup ](https://spatie.be/docs/rust-crawler/v1/installation-setup)
- [ Support us ](https://spatie.be/docs/rust-crawler/v1/support-us)
- [ Questions and issues ](https://spatie.be/docs/rust-crawler/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/rust-crawler/v1/changelog)
- [ About us ](https://spatie.be/docs/rust-crawler/v1/about-us)

Basic usage
-----------

- [ Your first crawl ](https://spatie.be/docs/rust-crawler/v1/basic-usage/starting-your-first-crawl)
- [ Crawl responses ](https://spatie.be/docs/rust-crawler/v1/basic-usage/handling-crawl-responses)
- [ Using observers ](https://spatie.be/docs/rust-crawler/v1/basic-usage/using-observers)
- [ Collecting URLs ](https://spatie.be/docs/rust-crawler/v1/basic-usage/collecting-urls)
- [ Filtering URLs ](https://spatie.be/docs/rust-crawler/v1/basic-usage/filtering-urls)
- [ Testing ](https://spatie.be/docs/rust-crawler/v1/basic-usage/testing)
- [ Tracking progress ](https://spatie.be/docs/rust-crawler/v1/basic-usage/tracking-progress)

Configuring the crawler
-----------------------

- [ Concurrency &amp; throttling ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/crawl-behavior)
- [ Limits ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/setting-crawl-limits)
- [ Extracting resources ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/extracting-resources)
- [ Configuring requests ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/configuring-requests)
- [ Response filtering ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/handling-responses)
- [ Respecting robots.txt ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/respecting-robots-txt)

Advanced usage
--------------

- [ JavaScript rendering ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/rendering-javascript)
- [ Custom link extraction ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/extracting-custom-links)
- [ Custom request handlers ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/custom-request-handlers)
- [ Crawling across requests ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/crawling-across-requests)
- [ Custom crawl queue ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/using-a-custom-crawl-queue)
- [ Graceful shutdown ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/graceful-shutdown)

 Tracking progress
=================

###  On this page 

1. [ Progress fields ](#content-progress-fields)
2. [ Finish reasons ](#content-finish-reasons)
3. [ Prometheus ](#content-prometheus)

Every event contains a `Progress` snapshot. Use it to report work without counting events yourself. Event counts and URL counts differ because a URL can cause several events.

```
use spatie_crawler::{CrawlEvent, Crawler};

fn configured() -> spatie_crawler::Result {
    Crawler::builder("https://example.com")?
        .on_event(|event| {
            if let CrawlEvent::Page { page, progress } = event {
                println!("{} succeeded, {} failed, {} queued: {}",
                    progress.succeeded, progress.failed, progress.queued, page.url);
            }
        })
        .build()
}
```

Progress fields
-----------------------------------------------------------------------------------------------------

FieldMeaning`discovered`URLs accepted into the store.`queued`URLs waiting for work.`in_flight`Claimed URL jobs.`succeeded` / `failed` / `skipped`Stored terminal outcomes.`attempted`URL fetch jobs started, excluding retries.`retries`Extra fetch attempts in this execution.`mapped`Stored mapping discoveries not fetched as pages.`malformed`Invalid references reported in this execution, not fetch failures.`elapsed_ms`Elapsed time in this execution.`total_elapsed_ms`Persisted elapsed time plus the current execution.Stored counts and attempt budgets survive checkpoint resumes. `retries`, `malformed` and `elapsed_ms` describe the current execution. Scope refusals can produce a `Skipped` event without becoming stored outcomes. A noindex page can contribute links while counting as a stored skip.

Finish reasons
--------------------------------------------------------------------------------------------------

The `Finished` event reports why scheduling stopped:

ReasonMeaning`Completed`No work remains.`PageLimit`An execution or cumulative page budget was reached.`TimeLimit`An execution or cumulative elapsed budget was reached.`Stopped`A handler or `stop_when` condition requested a stop.`Cancelled`The cancellation token was cancelled.`Failed`The scheduler or store failed; inspect `error`.`Completed` does not imply every URL succeeded. Check `progress.failed` too. Limits and application stops leave work for a later checkpoint execution. See [limits](../configuring-the-crawler/setting-crawl-limits).

Prometheus
--------------------------------------------------------------------------------------

`Progress::prometheus()` returns a text-format snapshot with fixed `crawler_*` gauge names and no URL labels. It includes `crawler_elapsed_seconds` for the current execution. Serve the latest snapshot from your application's metrics endpoint; the library does not start a server.

```
use spatie_crawler::CrawlEvent;

fn final_metrics(event: &CrawlEvent) -> Option {
    match event {
        CrawlEvent::Finished { progress, .. } => Some(progress.prometheus()),
        _ => None,
    }
}
```

The CLI can write a final snapshot:

```
rust-crawler crawl https://example.com --limit 100 --metrics crawl.prom
```

This writes a file at completion, not a live metrics endpoint. The CLI also supports `RUST_LOG` filtering for structured diagnostics on stderr. Protect logs and output files; URLs and page content can contain secrets.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
