Skip to content
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: 2 additions & 0 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,8 @@ def create_partitioned_queues(name):
# Enable usage of external relays, for use with Relay. See
# https://github.com/getsentry/relay.
"organizations:relay": True,
# Enable logging for weekly reports
"organizations:weekly-report-debugging": False,
# Enable Session Stats down to a minute resolution
"organizations:minute-resolution-sessions": True,
# Automatically opt IN users to receiving Slack notifications.
Expand Down
1 change: 1 addition & 0 deletions src/sentry/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
default_manager.add("organizations:prompt-dashboards", OrganizationFeature)
default_manager.add("organizations:related-events", OrganizationFeature)
default_manager.add("organizations:relay", OrganizationFeature)
default_manager.add("organizations:weekly-report-debugging", OrganizationFeature, True)
default_manager.add("organizations:release-adoption-chart", OrganizationFeature, True)
default_manager.add("organizations:release-adoption-stage", OrganizationFeature, True)
default_manager.add("organizations:release-archives", OrganizationFeature)
Expand Down
32 changes: 27 additions & 5 deletions src/sentry/tasks/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,16 @@ def deliver_organization_user_report(timestamp, duration, organization_id, user_
user = User.objects.get(id=user_id)

if not user_subscribed_to_organization_reports(user, organization):
if features.has("organizations:weekly-report-debugging", organization):
logger.info(
Copy link
Contributor

@mgaeta mgaeta Nov 3, 2021

Choose a reason for hiding this comment

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

If you don't mind doing something hacky I'd recommend:

log_level = "debug"
if features.has("organizations:weekly-report-debugging", organization):
    log_level = "info"

...

getattr(logger, log_level)(...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, I'm going to take it out in a few days anyway

"reports.user.unsubscribed",
extra={
"user": user.id,
"organization_id": organization.id,
},
)
logger.debug(
"Skipping report for %r to %r, user is not subscribed to reports.", organization, user
f"Skipping report for {organization} to {user}, user is not subscribed to reports."
)
return Skipped.NotSubscribed

Expand All @@ -715,10 +723,16 @@ def deliver_organization_user_report(timestamp, duration, organization_id, user_
projects.update(Project.objects.get_for_user(team, user, _skip_team_check=True))

if not projects:
if features.has("organizations:weekly-report-debugging", organization):
logger.info(
"reports.user.no_projects",
extra={
"user": user.id,
"organization_id": organization.id,
},
)
logger.debug(
"Skipping report for %r to %r, user is not associated with any projects.",
organization,
user,
f"Skipping report for {organization} to {user}, user is not associated with any projects."
)
return Skipped.NoProjects

Expand All @@ -738,8 +752,16 @@ def deliver_organization_user_report(timestamp, duration, organization_id, user_
)

if not reports:
if features.has("organizations:weekly-report-debugging", organization):
logger.info(
"reports.user.no_reports",
extra={
"user": user.id,
"organization_id": organization.id,
},
)
logger.debug(
"Skipping report for %r to %r, no qualifying reports to deliver.", organization, user
f"Skipping report for {organization} to {user}, no qualifying reports to deliver."
)
return Skipped.NoReports

Expand Down