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

Adding Config switch for Xray #2261

Merged
merged 1 commit into from
Aug 21, 2024
Merged

Adding Config switch for Xray #2261

merged 1 commit into from
Aug 21, 2024

Conversation

P0NDER0SA
Copy link
Contributor

@P0NDER0SA P0NDER0SA commented Aug 21, 2024

Summary | Résumé

Adding logic to rely upon an environment variable to turn Xray Tracing on or off

Related Issues | Cartes liées

https://app.zenhub.com/workspaces/notify-planning-core-6411dfb7c95fb80014e0cab0/issues/gh/cds-snc/notification-planning-core/400

Test instructions | Instructions pour tester la modification

  • Update the .env file on staging from true to false (or vice versa) on staging
  • Deploy the app on staging
  • Verify the Xray tracing/maps to see if it's on or off depending on configuration

Release Instructions | Instructions pour le déploiement

Verify the config value in the production .env file to ensure it's what we want it to be.

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

Copy link
Contributor

@ben851 ben851 left a comment

Choose a reason for hiding this comment

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

LGTM

@P0NDER0SA P0NDER0SA merged commit 70c478f into main Aug 21, 2024
4 checks passed
@P0NDER0SA P0NDER0SA deleted the xray-config-switch branch August 21, 2024 18:40
signals.task_postrun.connect(xray_task_postrun)
signals.task_prerun.connect(xray_task_prerun)
signals.beat_init.connect(xray_task_prerun)
if app.config["AWS_XRAY_ENABLED"] == "true":
Copy link
Member

@jimleroyer jimleroyer Aug 21, 2024

Choose a reason for hiding this comment

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

To minimize typo and typing errors, we want:
current_app.config["AWS_XRAY_ENABLED"] is True

But that would require for the AWS_XRAY_ENABLED constant to be declared using the bool function of the environs module as such:

AWS_XRAY_ENABLED = env.bool("AWS_XRAY_ENABLED", False)

The environs module is a nifty library to make configuration parsing more reliable in general.

@@ -240,6 +240,9 @@ class Config(object):
DEBUG = False
NOTIFY_LOG_PATH = os.getenv("NOTIFY_LOG_PATH")

# AWS Xray
AWS_XRAY_ENABLED = os.getenv("AWS_XRAY_ENABLED", "false")
Copy link
Member

Choose a reason for hiding this comment

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

AWS_XRAY_ENABLED = env.bool("AWS_XRAY_ENABLED", False)

XRayMiddleware(application, xray_recorder)
if application.config["AWS_XRAY_ENABLED"] == "true":
xray_recorder.configure(service='celery')
XRayMiddleware(application, xray_recorder)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how that XRayMiddleware object works, because we do not make use of it afterward. The xray_celery_handlers do get a hold of the xray_recorder via an import and I guess this might be a singleton? but the XRayMiddleware is just left alone afterward. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants