Usage
pip install scrapy-statsd-middleware
DOWNLOADER_MIDDLEWARES = {
'statsd_middleware.StatsdMiddleware': 543,
}
SPIDER_MIDDLEWARES = {
'statsd_middleware.StatsdMiddleware': 543,
}
There’s also a few settings that you can use:
STATSD_HOSTNAME - Defaults to the current machine’s hostname
STATSD_PREFIX - Defaults to “hostname.spider-name.”
STATSD_HOST_IP - Defaults to “0.0.0.0”
This will increment statsd with the following: * requests (spider_reqs_issued) * response (spider_resps_received) * errors (error_KeyError, where KeyError is whatever the error name is) * items processed (processed_Product, where Product is whatever the item class name is)
Example Implementation
An example implementation of this middleware is in /example It includes a docker-compose file that describes how to use this middleware with statsd & graphite
Example Installation & Usage
Build the docker images docker-compose build
Start the statsd container docker-compose up -d
Run the example spider: docker-compose -f ./example/docker-compose.yml run spider bash -c “cd ./opt/scrapy/dirbot/ && scrapy crawl dmoz”
You can see a live graphite dashboard at http://0.0.0.0/dashboard You should see stats show up under something like “stats.Z-MacBook-Pro.local.dmoz.spider_reqs_issued”
Development
You can run the tests via make test
Release files for scrapy-statsd-middleware 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scrapy-statsd-middleware-0.0.8.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scrapy_statsd_middleware-0.0.8-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / scrapy-statsd-middleware-0.0.8.tar.gz
| Download URL | scrapy-statsd-middleware-0.0.8.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
499854f9806caab56877f2e554e6588e70b1f747261ef0fe4c8623cc276f971a
|
|
BLAKE2b-256 checksum How to use checksums |
4443fe8bf448512933844d2d21403a2d044503834e907054d3b21aac9e07e6c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrapy_statsd_middleware-0.0.8-py2.py3-none-any.whl
| Download URL | scrapy_statsd_middleware-0.0.8-py2.py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
eead9a9c0e66464f7019dea8d574933fe7d45222761ae63fd54965b622a5d92a
|
|
BLAKE2b-256 checksum How to use checksums |
01be8c852e01ecaf12c75af8d83c45308422f06af415cd1fd2501e0c31c23348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |