Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry Integration in Release Monitor #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions openshift/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ objects:
secretKeyRef:
name: aws
key: s3-secret-access-key
- name: SENTRY_DSN
valueFrom:
secretKeyRef:
name: worker
key: sentry_dsn
# this won't get used if running with SQS
- name: RABBITMQ_SERVICE_SERVICE_HOST
value: bayesian-broker
Expand Down Expand Up @@ -175,3 +180,9 @@ parameters:
required: true
name: DEBUG
value: "False"

- description: Sentry DSN
displayName: Sentry DSN
required: false
name: SENTRY_DSN
value: ""
17 changes: 12 additions & 5 deletions release_monitor/release_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from f8a_worker.setup_celery import init_celery, init_selinon
from f8a_worker.utils import normalize_package_name
from selinon import run_flow
import sentry_sdk

# local imports:
from release_monitor.defaults import NPM_URL, PYPI_URL, ENABLE_SCHEDULING, SLEEP_INTERVAL
Expand All @@ -39,6 +40,7 @@ def set_up_logger():


logger = set_up_logger()
sentry_sdk.init(os.environ.get("SENTRY_DSN"))


class Package:
Expand Down Expand Up @@ -113,11 +115,13 @@ def create_package_from_pypi_dict(dict):
list_of_pypi_updates = feedparser.parse(self.pypi_url + "rss/updates.xml").entries
try:
updated_packages = set(map(create_package_from_pypi_dict, list_of_pypi_updates))
except KeyError:
except KeyError as e:
# if the "title" does not exist, catch the error and return nothing
logger.error('Titles does not exist : {e}'.format(e=str(e)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of logging these errors here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And by here I mean in the whole file :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msrb As I mentioned below, in case upstream format change, those logger.errors are beneficial to the developers to correct their code displayed in Sentry. If you think otherwise, we can make those into logger.info so that Sentry will not create event for that.

return set()
except IndexError:
except IndexError as e:
# if the "title" does not contain name and version, catch the error and return nothing
logger.error('name and version does not exist : {e}'.format(e=str(e)))
return set()

return updated_packages
Expand All @@ -138,7 +142,8 @@ def fetch_pkg_names_from_feed(self):
try:
r = set(map(lambda x: x['title'], npm_feed.entries))
return r
except KeyError:
except KeyError as e:
logger.error('npm package key not found : {e}'.format(e=str(e)))
return None

@staticmethod
Expand All @@ -151,11 +156,13 @@ def fetch_latest_package_version(package):
if req.status_code == 200:
body = req.json()
return body['latest']
except ValueError:
except ValueError as e:
# The body was not a valid JSON
logger.error('valid JSON key not found : {e}'.format(e=str(e)))
return None
except KeyError:
except KeyError as e:
# The body was a valid JSON, but it did not contain version field
logger.error('version key not found : {e}'.format(e=str(e)))
return None

def fetch_feed(self):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ psutil==5.4.8
requests==2.21.0
typing==3.6.6
urllib3==1.24.1 # via requests
sentry-sdk==0.7.2