Skip to content

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

Remove the OpenTelemetry requests instrumentor (#19986)

Marcin Wcisłodfbf13948fa0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36beae6b79..37b6154d7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -68,7 +68,7 @@ All notable, unreleased changes to this project will be documented in this file.
### Other changes
-- Added OpenTelemetry instrumentation for psycopg, Celery, Redis, requests and botocore. Spans for database queries, cache and broker commands, Celery tasks, outgoing HTTP requests and AWS calls are now emitted alongside Saleor's own spans, with Celery task spans linked to the request that scheduled them. The threading instrumentor is enabled too, so spans created in threads and thread pools, for example S3 calls that boto3 runs in its transfer threads, stay in the trace of the request or task that started them. Library instrumentors emit spans only, their metrics are not exported. The set of enabled instrumentors is controlled by the new `TELEMETRY_INSTRUMENTORS` environment variable, which takes a comma-separated list of OpenTelemetry instrumentor entry point names and defaults to `psycopg,celery,redis,requests,botocore,threading`. Set it to an empty string to disable library instrumentation. The OpenTelemetry packages were upgraded to SDK 1.37.0 and instrumentation 0.58b0.
+- Added OpenTelemetry instrumentation for psycopg, Celery, Redis and botocore. Spans for database queries, cache and broker commands, Celery tasks and AWS calls are now emitted alongside Saleor's own spans, with Celery task spans linked to the request that scheduled them. The threading instrumentor is enabled too, so spans created in threads and thread pools, for example S3 calls that boto3 runs in its transfer threads, stay in the trace of the request or task that started them. Outgoing HTTP requests are deliberately not instrumented, because the requests instrumentor would replace the `traceparent` header that apps receive with webhooks, which points at the `webhooks.<event>` span, with its own span. Library instrumentors emit spans only, their metrics are not exported. The set of enabled instrumentors is controlled by the new `TELEMETRY_INSTRUMENTORS` environment variable, which takes a comma-separated list of OpenTelemetry instrumentor entry point names and defaults to `psycopg,celery,redis,botocore,threading`. Set it to an empty string to disable library instrumentation. The OpenTelemetry packages were upgraded to SDK 1.37.0 and instrumentation 0.58b0.
- Dropped the database leftovers of the legacy digital content feature removed in 3.23: the `product_digitalcontent` and `product_digitalcontenturl` tables, and the `automatic_fulfillment_digital_products`, `default_digital_max_downloads` and `default_digital_url_valid_days` columns of `site_sitesettings`. Files uploaded through the legacy API are not removed from the media storage — the `digital_contents/` directory can be deleted manually.
- `ProductType.is_digital` was removed from the ORM model; the column itself will be dropped in 3.25.
- Removed the `is_digital` field from the `populatedb` sample data.
diff --git a/pyproject.toml b/pyproject.toml
index 722990aec0..2e178a0839 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,7 +73,6 @@ dependencies = [
"opentelemetry-instrumentation-celery>=0.58b0,<0.59",
"opentelemetry-instrumentation-psycopg>=0.58b0,<0.59",
"opentelemetry-instrumentation-redis>=0.58b0,<0.59",
- "opentelemetry-instrumentation-requests>=0.58b0,<0.59",
"opentelemetry-instrumentation-threading>=0.58b0,<0.59",
"celery[redis, sqs]>=5.6.3,<6.0.0",
"kombu[sqs]>=4.6.11,<6.0.0",
@@ -237,7 +236,7 @@ pillow = "PIL"
python-magic-bin = "magic"
[tool.deptry.per_rule_ignores]
-DEP002 = ["azure-common", "azure-storage-blob", "azure-storage-common", "django-redis", "psycopg", "pyxb", "opentelemetry-instrumentation-botocore", "opentelemetry-instrumentation-celery", "opentelemetry-instrumentation-psycopg", "opentelemetry-instrumentation-redis", "opentelemetry-instrumentation-requests", "opentelemetry-instrumentation-threading"]
+DEP002 = ["azure-common", "azure-storage-blob", "azure-storage-common", "django-redis", "psycopg", "pyxb", "opentelemetry-instrumentation-botocore", "opentelemetry-instrumentation-celery", "opentelemetry-instrumentation-psycopg", "opentelemetry-instrumentation-redis", "opentelemetry-instrumentation-threading"]
[tool.django-stubs]
django_settings_module = "saleor.settings"
diff --git a/saleor/core/telemetry/__init__.py b/saleor/core/telemetry/__init__.py
index b521162dd3..da0a98551b 100644
--- a/saleor/core/telemetry/__init__.py
+++ b/saleor/core/telemetry/__init__.py
@@ -49,10 +49,8 @@ def instrument_libraries(names: Iterable[str]) -> None:
"""
# Library instrumentors are used for spans only, their metrics are discarded on
# purpose by handing them a no-op MeterProvider. Saleor owns what goes to the
- # metric pipeline: the requests instrumentor would duplicate the webhook request
- # metrics recorded in saleor.webhook.transport.metrics, with extra port and
- # status dimensions multiplying the series, and the Celery task runtime histogram
- # is not needed. Keeping the metric set fixed also keeps its cost predictable.
+ # metric pipeline: the Celery task runtime histogram, for example, is not needed.
+ # Keeping the metric set fixed also keeps its cost predictable.
meter_provider = NoOpMeterProvider()
enabled = []
for name in names:
diff --git a/saleor/core/telemetry/tests/test_init.py b/saleor/core/telemetry/tests/test_init.py
index efd0fadff6..e8b3ed0293 100644
--- a/saleor/core/telemetry/tests/test_init.py
+++ b/saleor/core/telemetry/tests/test_init.py
@@ -11,7 +11,6 @@ DEFAULT_INSTRUMENTORS = [
"psycopg",
"celery",
"redis",
- "requests",
"botocore",
"threading",
]
diff --git a/saleor/settings.py b/saleor/settings.py
index dd16a413e1..895a94232a 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -1218,15 +1218,16 @@ TELEMETRY_METER_CLASS = "saleor.core.telemetry.metric.Meter"
# OpenTelemetry library instrumentors enabled when telemetry is initialized, by
# entry point name in the `opentelemetry_instrumentor` group (registered by the
# opentelemetry-instrumentation-* packages). They produce spans for database
-# queries, cache and broker calls, outgoing HTTP requests and Celery tasks. The
+# queries, cache and broker calls, AWS calls and Celery tasks. The
# threading instrumentor produces no spans of its own, it carries the current trace
# context into threads and thread pools (for example the ones boto3 uses for S3
# uploads and downloads), so spans created there keep their parent.
+#
+# The requests instrumentor (opentelemetry-instrumentation-requests) is deliberately not installed and must not be added here. It opens its own span for every outgoing HTTP request and writes that span's context into the `traceparent` header. For webhooks this overwrites the `traceparent` that `send_webhook_using_http` injects for the `webhooks.<event>` span, so apps would continue the instrumentor's span instead of the webhook span, and the header sent would differ from the one stored in the delivery attempt's `request_headers`. Every other outgoing call would get a `traceparent` with internal span ids.
+#
# Set to an empty string to disable library instrumentation.
TELEMETRY_INSTRUMENTORS = get_list(
- os.environ.get(
- "TELEMETRY_INSTRUMENTORS", "psycopg,celery,redis,requests,botocore,threading"
- )
+ os.environ.get("TELEMETRY_INSTRUMENTORS", "psycopg,celery,redis,botocore,threading")
)
# Whether to raise or log exceptions for telemetry unit conversion errors
# Disabled by default to prevent disruptions caused by unexpected unit conversion issues
diff --git a/uv.lock b/uv.lock
index f1e15b4e3d..10302754fb 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1703,21 +1703,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/e3/c0/2a1d5a6950823369f11c19793ed79e882a8b7402de50b890f86541907245/opentelemetry_instrumentation_redis-0.58b0-py3-none-any.whl", hash = "sha256:d58fdf2103e437f927e14606145f7066336aa11429f757783bff2e56e1b99eba", size = 14927, upload-time = "2025-09-11T11:41:50.413Z" },
]
-[[package]]
-name = "opentelemetry-instrumentation-requests"
-version = "0.58b0"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "opentelemetry-api" },
- { name = "opentelemetry-instrumentation" },
- { name = "opentelemetry-semantic-conventions" },
- { name = "opentelemetry-util-http" },
-]
-sdist = { url = "https://files.pythonhosted.org/packages/36/42/83ee32de763b919779aaa595b60c5a7b9c0a4b33952bbe432c5f6a783085/opentelemetry_instrumentation_requests-0.58b0.tar.gz", hash = "sha256:ae9495e6ff64e27bdb839fce91dbb4be56e325139828e8005f875baf41951a2e", size = 15188, upload-time = "2025-09-11T11:42:51.268Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/90/4d/f3476b28ea167d1762134352d01ae9693940a42c78994d9f1b32a4477816/opentelemetry_instrumentation_requests-0.58b0-py3-none-any.whl", hash = "sha256:672a0be0bb5b52bea0c11820b35e27edcf4cd22d34abe4afc59a92a80519f8a8", size = 12966, upload-time = "2025-09-11T11:41:52.67Z" },
-]
-
[[package]]
name = "opentelemetry-instrumentation-threading"
version = "0.58b0"
@@ -1783,15 +1768,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/07/90/68152b7465f50285d3ce2481b3aec2f82822e3f52e5152eeeaf516bab841/opentelemetry_semantic_conventions-0.58b0-py3-none-any.whl", hash = "sha256:5564905ab1458b96684db1340232729fce3b5375a06e140e8904c78e4f815b28", size = 207954, upload-time = "2025-09-11T10:28:59.218Z" },
]
-[[package]]
-name = "opentelemetry-util-http"
-version = "0.58b0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/c6/5f/02f31530faf50ef8a41ab34901c05cbbf8e9d76963ba2fb852b0b4065f4e/opentelemetry_util_http-0.58b0.tar.gz", hash = "sha256:de0154896c3472c6599311c83e0ecee856c4da1b17808d39fdc5cce5312e4d89", size = 9411, upload-time = "2025-09-11T11:43:05.602Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/a5/a3/0a1430c42c6d34d8372a16c104e7408028f0c30270d8f3eb6cccf2e82934/opentelemetry_util_http-0.58b0-py3-none-any.whl", hash = "sha256:6c6b86762ed43025fbd593dc5f700ba0aa3e09711aedc36fd48a13b23d8cb1e7", size = 7652, upload-time = "2025-09-11T11:42:09.682Z" },
-]
-
[[package]]
name = "orjson"
version = "3.11.9"
@@ -2642,7 +2618,6 @@ dependencies = [
{ name = "opentelemetry-instrumentation-celery" },
{ name = "opentelemetry-instrumentation-psycopg" },
{ name = "opentelemetry-instrumentation-redis" },
- { name = "opentelemetry-instrumentation-requests" },
{ name = "opentelemetry-instrumentation-threading" },
{ name = "opentelemetry-sdk" },
{ name = "opentelemetry-semantic-conventions" },
@@ -2754,7 +2729,6 @@ requires-dist = [
{ name = "opentelemetry-instrumentation-celery", specifier = ">=0.58b0,<0.59" },
{ name = "opentelemetry-instrumentation-psycopg", specifier = ">=0.58b0,<0.59" },
{ name = "opentelemetry-instrumentation-redis", specifier = ">=0.58b0,<0.59" },
- { name = "opentelemetry-instrumentation-requests", specifier = ">=0.58b0,<0.59" },
{ name = "opentelemetry-instrumentation-threading", specifier = ">=0.58b0,<0.59" },
{ name = "opentelemetry-sdk", specifier = ">=1.37.0,<2" },
{ name = "opentelemetry-semantic-conventions", specifier = ">=0.58b0,<0.59" },