Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #402 from GreatFruitOmsk/issue_398
Browse files Browse the repository at this point in the history
Add release submission to Sentry
  • Loading branch information
vpetersson committed Sep 6, 2019
2 parents 51b5b7c + b5d8135 commit 0f46941
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- run:
name: Build docker images
command: |
docker-compose -p api build
docker-compose -p api build --build-arg CIRCLE_SHA1=${CIRCLE_SHA1}
- run:
name: Build docker test images
command: |
Expand All @@ -68,18 +68,18 @@ jobs:
if [ "${CIRCLE_BRANCH}" == "master" ]; then
source $BASH_ENV
echo "$GCR_CREDS" | docker login -u _json_key --password-stdin https://gcr.io
echo "$GCR_CREDS" | docker login -u _json_key --password-stdin https://gcr.io
docker tag wott-api gcr.io/wott-prod/wott-api:${GITHASH}
docker tag wott-api gcr.io/wott-prod/wott-api:latest
docker tag wott-static gcr.io/wott-prod/wott-static:${GITHASH}
docker tag wott-static gcr.io/wott-prod/wott-static:latest
docker tag wott-api gcr.io/wott-prod/wott-api:${GITHASH}
docker tag wott-api gcr.io/wott-prod/wott-api:latest
docker tag wott-static gcr.io/wott-prod/wott-static:${GITHASH}
docker tag wott-static gcr.io/wott-prod/wott-static:latest
docker push gcr.io/wott-prod/wott-api:${GITHASH}
docker push gcr.io/wott-prod/wott-api:latest
docker push gcr.io/wott-prod/wott-static:${GITHASH}
docker push gcr.io/wott-prod/wott-static:latest
echo "Pushed gcr.io/wott-prod/wott-api:${GITHASH}"
docker push gcr.io/wott-prod/wott-api:${GITHASH}
docker push gcr.io/wott-prod/wott-api:latest
docker push gcr.io/wott-prod/wott-static:${GITHASH}
docker push gcr.io/wott-prod/wott-static:latest
echo "Pushed gcr.io/wott-prod/wott-api:${GITHASH}"
fi
- run:
name: Deploy to GKE
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ENV CFSSL_SERVER wott-ca
# This is such that we can override it during build
ARG DJANGO_SETTINGS_MODULE=backend.settings.prod
ENV DJANGO_SETTINGS_MODULE ${DJANGO_SETTINGS_MODULE}
ARG CIRCLE_SHA1=UNKNOWN
RUN echo ${CIRCLE_SHA1} > /usr/src/release.txt

USER nobody
CMD gunicorn \
Expand Down
6 changes: 5 additions & 1 deletion backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ def check_ip_range(ipr):
SENTRY_DSN = os.getenv('SENTRY_DSN')
if SENTRY_DSN:
import sentry_sdk

with open(os.path.join(REPO_DIR, 'release.txt'), 'r') as release_file:
release = release_file.read().strip()

from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(SENTRY_DSN, integrations=[DjangoIntegration()])
sentry_sdk.init(SENTRY_DSN, integrations=[DjangoIntegration()], release=release)

# 'tagulous'
SERIALIZATION_MODULES = {
Expand Down
5 changes: 3 additions & 2 deletions backend/monitoring/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.urls import path

from .views import CeleryPulseTimestampView
from .views import CeleryPulseTimestampView, ErrorView

urlpatterns = [
path('celery/', CeleryPulseTimestampView.as_view(), name='celery_pulse')
path('celery/', CeleryPulseTimestampView.as_view(), name='celery_pulse'),
path('error/', ErrorView.as_view(), name='error')
]
10 changes: 10 additions & 0 deletions backend/monitoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ class CeleryPulseTimestampView(LoginRequiredMixin, StaffuserRequiredMixin, View)
def get(self, request, *args, **kwargs):
pulse_obj = CeleryPulseTimestamp.objects.order_by('id').first()
return HttpResponse(str(pulse_obj.timestamp) if pulse_obj else 'None', content_type='text/plain')


class ErrorView(LoginRequiredMixin, StaffuserRequiredMixin, View):
"""
A view for raising (for testing purposes) an uncaught Django exceptions (500).
"""

def get(self, request, *args, **kwargs):
_ = 5 / 0 # ZeroDivisionError
return HttpResponse('No error', content_type='text/plain')
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
- DATASTORE_KEY_JSON
build:
context: .
args:
- CIRCLE_SHA1
image: wott-api:latest
volumes:
- ./backend:/usr/src/app
Expand All @@ -40,7 +42,6 @@ services:
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
image: api:latest
build:
context: .
volumes:
Expand Down

0 comments on commit 0f46941

Please sign in to comment.