This repository has been archived by the owner on Jan 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
158-simplify-cloudwatch-to-graphite-app-remove-leadbutt-dependency
Refactor/ simplification of the app: * Remove `pipe-watchdog.py` entirely * We're no longer using pipes to direct the output. An error should be output to the cloudwatch error logs on failure `cf logs --recent digitalmarketplace-cloudwatch-to-graphite-preview` * Remove this from the run command in `manifest.yml.example` * Add `flake8` dependency and `.flake8` file in line with GDS recommendations * Activate travis service on repo to check Flake8 rules and requirements files * Add `.travis.yml` * Add `Makefile` with shortcuts for running requirements freeze and flake8 * Update `README.md` * Change requirements handling * Add `requirements-app.txt` * Ensure `requirements.txt` contains full pinned requirements * Add `flake8` requirement for devs * Rewrite `app.py` * Add function descriptions to all functions * Remove dependency on `leadbutt`, `signal` and `subprocess` * Use `boto3` instead of `leadbutt`s `boto` (https://github.com/crccheck/cloudwatch-to-graphite/blob/master/leadbutt.py#L25) * Remove `get_timestamp` method. The same can be achieved with `time.time` * `logger.warn` is deprecated, use `logger.warning` instead * Bring string formatting in line with rest of strings in file * Rename `initialize_metrics ` to `create_hostedgraphite_base_metrics` for better description * Remove `call_leadbutt` function and replace with code calling aws ourselves. Extrapolated from (https://github.com/crccheck/cloudwatch-to-graphite/blob/master/leadbutt.py) * Change `loglevel` to `INFO` this is all that is required now we're not piping output * Move retry decorator on to wrapper method in `if __name__` block * Update `config.yaml.j2` template * `Dimensions` default = `{}` to avoid type manipulations * Remove `Auth` section from config. This can be hard coded until we have any need to specify it as a config variable * Remove `Options.Count` again, this can be hard coded. It's only used in one place and we've never needed to change it Extrapolate code out of leadbutt This code drops leadbutts retry functionality. Boto3 has the capacity to retry failed attempts. We should prefer this.
- Loading branch information
Showing
12 changed files
with
150 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,5 @@ | |
|
||
# App requirements | ||
!app.py | ||
!pipe-watchdog.py | ||
!config.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
exclude = venv*,__pycache__,.git | ||
max-line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: python | ||
sudo: false | ||
python: | ||
- "3.6" | ||
dist: "trusty" | ||
install: | ||
- pip install -r requirements-dev.txt | ||
script: | ||
- make test-requirements test-flake8 | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SHELL := /bin/bash | ||
VIRTUALENV_ROOT := $(shell [ -z $$VIRTUAL_ENV ] && echo $$(pwd)/venv || echo $$VIRTUAL_ENV) | ||
|
||
.PHONY: virtualenv | ||
virtualenv: | ||
[ -z $$VIRTUAL_ENV ] && [ ! -d venv ] && python3 -m venv venv || true | ||
|
||
.PHONY: test-flake8 | ||
test-flake8: virtualenv | ||
${VIRTUALENV_ROOT}/bin/flake8 . | ||
|
||
.PHONY: freeze-requirements | ||
freeze-requirements: | ||
rm -rf venv-freeze | ||
python3 -m venv venv-freeze | ||
$$(pwd)/venv-freeze/bin/pip install -r requirements-app.txt | ||
echo '# This file is autogenerated. Do not edit it manually.' > requirements.txt | ||
cat requirements-app.txt >> requirements.txt | ||
echo '' >> requirements.txt | ||
$$(pwd)/venv-freeze/bin/pip freeze -r <(sed '/^--/d' requirements-app.txt) | sed -n '/The following requirements were added by pip freeze/,$$p' >> requirements.txt | ||
rm -rf venv-freeze | ||
|
||
.PHONY: test-requirements | ||
test-requirements: | ||
@diff requirements-app.txt requirements.txt | grep '<' \ | ||
&& { echo "requirements.txt doesn't match requirements-app.txt."; \ | ||
echo "Run 'make freeze-requirements' to update."; exit 1; } \ | ||
|| { echo "requirements.txt is up to date"; exit 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
retrying==1.3.3 | ||
requests==2.17.3 | ||
PyYAML==3.13 | ||
boto3==1.9.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-r requirements.txt | ||
|
||
Jinja2==2.10 | ||
flake8==3.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
# This file is autogenerated. Do not edit it manually. | ||
retrying==1.3.3 | ||
cloudwatch-to-graphite==0.9.2 | ||
requests==2.17.3 | ||
requests==2.17.3 | ||
PyYAML==3.13 | ||
boto3==1.9.6 | ||
|
||
## The following requirements were added by pip freeze: | ||
botocore==1.12.7 | ||
certifi==2018.8.24 | ||
chardet==3.0.4 | ||
docutils==0.14 | ||
idna==2.5 | ||
jmespath==0.9.3 | ||
python-dateutil==2.7.3 | ||
s3transfer==0.1.13 | ||
six==1.11.0 | ||
urllib3==1.21.1 |