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

Show if Sentry environment variable is configured in show_version #86

Merged
merged 1 commit into from
Oct 4, 2024
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
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'
Loading