Skip to content

Commit

Permalink
Show if Sentry environment variable is configured in show_version
Browse files Browse the repository at this point in the history
  • Loading branch information
andresdelfino committed Jun 23, 2024
1 parent 5e297a6 commit a98c8ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/run_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from pycamp_bot.commands import schedule
from pycamp_bot.commands import announcements
from pycamp_bot.commands import devtools
from pycamp_bot.constants import SENTRY_DATA_SOURCE_NAME_ENVVAR
from pycamp_bot.models import models_db_connection
from pycamp_bot.logger import logger


SENTRY_DATA_SOURCE_NAME_ENVVAR = 'SENTRY_DATA_SOURCE_NAME'
if SENTRY_DATA_SOURCE_NAME_ENVVAR in os.environ:
sentry_sdk.init(dsn=os.environ[SENTRY_DATA_SOURCE_NAME_ENVVAR])

Expand Down
8 changes: 8 additions & 0 deletions src/pycamp_bot/commands/devtools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import subprocess
import sys

from telegram.ext import CommandHandler

from pycamp_bot.constants import SENTRY_DATA_SOURCE_NAME_ENVVAR
from pycamp_bot.utils import escape_markdown


Expand All @@ -28,6 +30,11 @@ async def show_version(update, context):
for pip_line in pip_freeze.stdout.decode().splitlines():
dependencies.append(escape_markdown(pip_line))

if SENTRY_DATA_SOURCE_NAME_ENVVAR in os.environ:
sentry_envvar_set = '🟢'
else:
sentry_envvar_set = '🔴'

lines = [
f'Commit deployado: `{commit}`',
f'Fecha del commit \\(author date\\): `{escape_markdown(author_date)}`',
Expand All @@ -37,6 +44,7 @@ async def show_version(update, context):
'```',
*dependencies,
'```',
f'Variable de entorno de Sentry definida: {sentry_envvar_set}',
]

await update.message.reply_text('\n'.join(lines), parse_mode='MarkdownV2')
Expand Down
1 change: 1 addition & 0 deletions src/pycamp_bot/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SENTRY_DATA_SOURCE_NAME_ENVVAR = 'SENTRY_DATA_SOURCE_NAME'

0 comments on commit a98c8ee

Please sign in to comment.