os.path.join(os.path.dirname(__file__), 'chalicelib')) # noqa sys.path.insert(0, pkg_root) # noqa from dss import BucketConfig, Config, DeploymentStage, create_app from dss.logging import configure_lambda_logging from dss.util import paginate from dss.util.tracing import DSS_XRAY_TRACE if DSS_XRAY_TRACE: # noqa from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core.context import Context from aws_xray_sdk.ext.flask.middleware import XRayMiddleware xray_recorder.configure( service='DSS', dynamic_naming=f"*{os.environ['API_DOMAIN_NAME']}*", context=Context(), context_missing='LOG_ERROR') configure_lambda_logging() Config.set_config(BucketConfig.NORMAL) Config.BLOBSTORE_CONNECT_TIMEOUT = 5 Config.BLOBSTORE_READ_TIMEOUT = 5 Config.BLOBSTORE_BOTO_RETRIES = 2 Config.BLOBSTORE_GS_MAX_CUMULATIVE_RETRY = 15 EXECUTION_TERMINATION_THRESHOLD_SECONDS = 5.0 """We will terminate execution if we have this many seconds left to process the request.""" API_GATEWAY_TIMEOUT_SECONDS = 30.0 """
return 'Not Found', 404 @app.route('/fault') def fault(): return {}['key'] @app.route('/template') def template(): return render_template_string('hello template') # add X-Ray middleware to flask app recorder = get_new_stubbed_recorder() recorder.configure(service='test', sampling=False, context=Context()) XRayMiddleware(app, recorder) # enable testing mode app.config['TESTING'] = True app = app.test_client() BASE_URL = 'http://localhost{}' @pytest.fixture(autouse=True) def cleanup(): """ Clean up context storage before and after each test run """ recorder.clear_trace_entities()
def __init__(self): self._xray_client = self._create_xray_client() self._client_id = binascii.b2a_hex(os.urandom(12)).decode('utf-8') self._context = Context()
def setup(): django.setup() xray_recorder.configure(context=Context(), context_missing='LOG_ERROR') patch_db()
def setUp(self): django.setup() xray_recorder.configure(context=Context(), context_missing='LOG_ERROR') xray_recorder.clear_trace_entities() global_sdk_config.set_sdk_enabled(True)
def setUp(self): django.setup() xray_recorder.configure(context=Context(), context_missing='LOG_ERROR') xray_recorder.clear_trace_entities()