Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[settings]
known_first_party = code_coverage_backend,code_coverage_bot,code_coverage_tools,conftest
known_third_party = connexion,datadog,dateutil,fakeredis,flask,flask_cors,flask_talisman,google,hglib,jsone,jsonschema,libmozdata,logbook,pytest,pytz,redis,requests,responses,setuptools,structlog,taskcluster,werkzeug,zstandard
known_third_party = connexion,datadog,dateutil,fakeredis,flask,flask_cors,flask_talisman,google,hglib,jsone,jsonschema,libmozdata,logbook,pytest,pytz,raven,redis,requests,responses,setuptools,structlog,taskcluster,werkzeug,zstandard
force_single_line = True
default_section=FIRSTPARTY
line_length=159
2 changes: 1 addition & 1 deletion backend/code_coverage_backend/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_app():
code_coverage_backend.config.PROJECT_NAME,
PAPERTRAIL_HOST=taskcluster.secrets.get("PAPERTRAIL_HOST"),
PAPERTRAIL_PORT=taskcluster.secrets.get("PAPERTRAIL_PORT"),
SENTRY_DSN=taskcluster.secrets.get("SENTRY_DSN"),
sentry_dsn=taskcluster.secrets.get("SENTRY_DSN"),
)
logger = structlog.get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion bot/ci/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -ex
GRCOV_VERSION="v0.5.1"
GRCOV_VERSION="v0.5.3"
MERCURIAL_VERSION="4.8"

apt-get update
Expand Down
3 changes: 2 additions & 1 deletion bot/code_coverage_bot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def main():

init_logger(
config.PROJECT_NAME,
channel=secrets.get("APP_CHANNEL", "dev"),
PAPERTRAIL_HOST=secrets.get("PAPERTRAIL_HOST"),
PAPERTRAIL_PORT=secrets.get("PAPERTRAIL_PORT"),
SENTRY_DSN=secrets.get("SENTRY_DSN"),
sentry_dsn=secrets.get("SENTRY_DSN"),
)

c = CodeCov(args.repository, args.revision, args.task_name_filter, args.cache_root)
Expand Down
10 changes: 9 additions & 1 deletion bot/code_coverage_bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ def run_check(command, **kwargs):
output, error = proc.communicate()

if proc.returncode != 0:
log.info(
if isinstance(output, bytes):
output = output.decode("utf-8")
if isinstance(error, bytes):
error = error.decode("utf-8")

# Use error to send log to sentry
log.error(
f"Command failed with code: {proc.returncode}",
exit=proc.returncode,
command=" ".join(command),
output=output,
error=error,
)

raise RunException(f"`{command[0]}` failed with code: {proc.returncode}.")

return output
Expand Down
32 changes: 15 additions & 17 deletions tools/code_coverage_tools/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import logbook
import logbook.more
import raven
import raven.handlers.logbook
import structlog


Expand Down Expand Up @@ -42,24 +44,20 @@ def setup_papertrail(project_name, channel, PAPERTRAIL_HOST, PAPERTRAIL_PORT):
papertrail.push_application()


def setup_sentry(project_name, channel, SENTRY_DSN):
def setup_sentry(name, channel, dsn):
"""
Setup sentry account using taskcluster secrets
"""

import raven
import raven.handlers.logbook

sentry_client = raven.Client(
dsn=SENTRY_DSN,
site=project_name,
name="mozilla/release-services",
environment=channel,
# TODO:
# release=read(VERSION) we need to promote that as well via secrets
# tags=...
# repos=...
)
# Detect environment
if "TASK_ID" in os.environ:
site = "taskcluster"
elif "DYNO" in os.environ:
site = "heroku"
else:
site = "unknown"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be local, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap


sentry_client = raven.Client(dsn=dsn, site=site, name=name, environment=channel)

sentry_handler = raven.handlers.logbook.SentryHandler(
sentry_client, level=logbook.WARNING, bubble=True
Expand All @@ -73,7 +71,7 @@ def init_logger(
level=logbook.INFO,
PAPERTRAIL_HOST=None,
PAPERTRAIL_PORT=None,
SENTRY_DSN=None,
sentry_dsn=None,
):

if not channel:
Expand All @@ -89,8 +87,8 @@ def init_logger(
setup_papertrail(project_name, channel, PAPERTRAIL_HOST, PAPERTRAIL_PORT)

# Log to senty
if channel and SENTRY_DSN:
setup_sentry(project_name, channel, SENTRY_DSN)
if channel and sentry_dsn:
setup_sentry(project_name, channel, sentry_dsn)

def logbook_factory(*args, **kwargs):
# Logger given to structlog
Expand Down
1 change: 1 addition & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
logbook
structlog
taskcluster
raven