fix flask undefined client
@@ -88,17 +88,9 @@ class ElasticAPM(object):
self.app = app
self.logging = logging
self.client = client or get_client()
+ self.client_cls = client_cls
if app:
- if not self.client:
- config = app.config.get("ELASTIC_APM", {})
-
- if "framework_name" not in defaults:
- defaults["framework_name"] = "flask"
- defaults["framework_version"] = getattr(flask, "__version__", "<0.7")
-
- self.client = client_cls(config, **defaults)
-
self.init_app(app, **defaults)
def handle_exception(self, *args, **kwargs):
@@ -123,6 +115,14 @@ class ElasticAPM(object):
def init_app(self, app, **defaults):
self.app = app
+ if not self.client:
+ config = self.app.config.get("ELASTIC_APM", {})
+
+ if "framework_name" not in defaults:
+ defaults["framework_name"] = "flask"
+ defaults["framework_version"] = getattr(flask, "__version__", "<0.7")
+
+ self.client = self.client_cls(config, **defaults)
# 0 is a valid log level (NOTSET), so we need to check explicitly for it
if self.logging or self.logging is logging.NOTSET:
