Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Turn off Jaeger during pytest (#15718)

Filip Owczarek1d47e4485eb4
diff --git a/saleor/settings.py b/saleor/settings.py
index 3c70df8960..e0acb03a38 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -805,7 +805,8 @@ RESERVE_DURATION = 45
#
# If running locally, set:
# JAEGER_AGENT_HOST=localhost
-if "JAEGER_AGENT_HOST" in os.environ:
+JAEGER_HOST = os.environ.get("JAEGER_AGENT_HOST")
+if JAEGER_HOST:
jaeger_client.Config(
config={
"sampler": {"type": "const", "param": 1},
@@ -813,7 +814,7 @@ if "JAEGER_AGENT_HOST" in os.environ:
"reporting_port": os.environ.get(
"JAEGER_AGENT_PORT", jaeger_client.config.DEFAULT_REPORTING_PORT
),
- "reporting_host": os.environ.get("JAEGER_AGENT_HOST"),
+ "reporting_host": JAEGER_HOST,
},
"logging": get_bool_from_env("JAEGER_LOGGING", False),
},
diff --git a/saleor/tests/settings.py b/saleor/tests/settings.py
index e2e376ef3f..deb5301734 100644
--- a/saleor/tests/settings.py
+++ b/saleor/tests/settings.py
@@ -1,9 +1,14 @@
+import os
import re
from re import Pattern
from typing import Union
from django.utils.functional import SimpleLazyObject
+# Disable Jaeger tracing should be done before importing settings.
+# without this line pytest will start sending traces to Jaeger agent.
+os.environ["JAEGER_AGENT_HOST"] = ""
+
from ..settings import * # noqa