Skip to content

Fixes to publish logs on papertrail #191

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

Merged
merged 4 commits into from
Sep 25, 2019
Merged
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
3 changes: 2 additions & 1 deletion backend/code_coverage_backend/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def create_app():

# Configure logger
init_logger(
code_coverage_backend.config.PROJECT_NAME,
"backend",
channel=taskcluster.secrets.get("APP_CHANNEL", "dev"),
PAPERTRAIL_HOST=taskcluster.secrets.get("PAPERTRAIL_HOST"),
PAPERTRAIL_PORT=taskcluster.secrets.get("PAPERTRAIL_PORT"),
sentry_dsn=taskcluster.secrets.get("SENTRY_DSN"),
Expand Down
3 changes: 1 addition & 2 deletions bot/code_coverage_bot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import argparse
import os

from code_coverage_bot import config
from code_coverage_bot.secrets import secrets
from code_coverage_bot.taskcluster import taskcluster_config
from code_coverage_tools.log import init_logger
Expand Down Expand Up @@ -50,7 +49,7 @@ def setup_cli(ask_repository=True, ask_revision=True):
secrets.load(args.taskcluster_secret)

init_logger(
config.PROJECT_NAME,
"bot",
channel=secrets.get("APP_CHANNEL", "dev"),
PAPERTRAIL_HOST=secrets.get("PAPERTRAIL_HOST"),
PAPERTRAIL_PORT=secrets.get("PAPERTRAIL_PORT"),
Expand Down
7 changes: 5 additions & 2 deletions events/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM python:3-slim

ADD events /src

RUN cd /src && pip install --disable-pip-version-check --no-cache-dir -r requirements.txt && python setup.py install
ADD tools /src/tools
ADD events /src/events

RUN cd /src/tools && python setup.py install
RUN cd /src/events && python setup.py install

CMD ["code-coverage-events"]
7 changes: 4 additions & 3 deletions events/code_coverage_events/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import structlog
from libmozevent import taskcluster_config
from libmozevent.log import init_logger

from code_coverage_events.workflow import Events
from code_coverage_tools.log import init_logger

logger = structlog.get_logger(__name__)

Expand Down Expand Up @@ -37,10 +37,11 @@ def main():
)

init_logger(
"code_coverage_events",
"events",
channel=taskcluster_config.secrets.get("APP_CHANNEL", "dev"),
PAPERTRAIL_HOST=taskcluster_config.secrets.get("PAPERTRAIL_HOST"),
PAPERTRAIL_PORT=taskcluster_config.secrets.get("PAPERTRAIL_PORT"),
SENTRY_DSN=taskcluster_config.secrets.get("SENTRY_DSN"),
sentry_dsn=taskcluster_config.secrets.get("SENTRY_DSN"),
)

events = Events()
Expand Down
1 change: 1 addition & 0 deletions events/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-e ../tools #egg=code-coverage-tools
libmozevent==1.0.0
20 changes: 18 additions & 2 deletions events/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@


def read_requirements(file_):
with open(os.path.join(here, file_)) as f:
return sorted(list(set(line.split("#")[0].strip() for line in f)))
lines = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Back to being complex :P

with open(file_) as f:
for line in f.readlines():
line = line.strip()
if (
line.startswith("-e ")
or line.startswith("http://")
or line.startswith("https://")
):
extras = ""
if "[" in line:
extras = "[" + line.split("[")[1].split("]")[0] + "]"
line = line.split("#")[1].split("egg=")[1] + extras
elif line == "" or line.startswith("#") or line.startswith("-"):
continue
line = line.split("#")[0].strip()
lines.append(line)
return sorted(list(set(lines)))


with open(os.path.join(here, "VERSION")) as f:
Expand Down
2 changes: 1 addition & 1 deletion tools/code_coverage_tools/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setup_papertrail(project_name, channel, PAPERTRAIL_HOST, PAPERTRAIL_PORT):

# Setup papertrail
papertrail = logbook.SyslogHandler(
application_name=f"mozilla/release-services/{channel}/{project_name}",
application_name=f"code-coverage/{channel}/{project_name}",
address=(PAPERTRAIL_HOST, int(PAPERTRAIL_PORT)),
level=logbook.INFO,
format_string="{record.time} {record.channel}: {record.message}",
Expand Down