Skip to content

Commit

Permalink
Adding Xray SDK and Recorder Code (#2231)
Browse files Browse the repository at this point in the history
* Adding the xray sdk and adding the recorder code to the application

* sorting imports

* removing blank lines

* adding stub packages

* ignoring missing imports for xray

* removing the types as we now ignore them

* moving this code as this is more correct
  • Loading branch information
P0NDER0SA authored Jul 25, 2024
1 parent 6e6abb4 commit 30a39c1
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
7 changes: 6 additions & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import newrelic.agent # See https://bit.ly/2xBVKBH
from apig_wsgi import make_lambda_handler
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.ext.flask.middleware import XRayMiddleware
from dotenv import load_dotenv
from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
Expand All @@ -13,11 +15,14 @@

load_dotenv()


application = Flask("api")
application.wsgi_app = ProxyFix(application.wsgi_app) # type: ignore

app = create_app(application)

xray_recorder.configure(service='api')
XRayMiddleware(app, xray_recorder)

apig_wsgi_handler = make_lambda_handler(app, binary_support=True)

if os.environ.get("USE_LOCAL_JINJA_TEMPLATES") == "True":
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ ignore_missing_imports = True
ignore_missing_imports = True

[mypy-simple_salesforce.*]
ignore_missing_imports = True

[mypy-aws_xray_sdk.*]
ignore_missing_imports = True
96 changes: 95 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ simple-salesforce = "^1.12.3"
certifi = "^2023.7.22" # pinned for security reasons: https://github.com/cds-snc/notification-api/security/dependabot/119
idna = "2.10" # pinned to align with test moto dependency requirements (for <=2.9)
flask-marshmallow = "0.14.0"
aws-xray-sdk = "^2.14.0"

[tool.poetry.group.test.dependencies]
flake8 = "6.1.0"
Expand Down

0 comments on commit 30a39c1

Please sign in to comment.