Skip to content

Commit 4beed5f

Browse files
pvitalGSVarsha
authored andcommitted
refactor: Remove legacy INSTANA_DISABLE handling.
The `INSTANA_DISABLE` is not a general environment variable from Instana, and with the adoption of the new `INSTANA_TRACING_DISABLE` we can have the same effect. So this commit removes the legacy one. Signed-off-by: Paulo Vital <[email protected]>
1 parent 5f7b80c commit 4beed5f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/instana/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"""
1212

1313
import importlib
14-
import importlib.util
1514
import os
1615
import sys
16+
from importlib import util as importlib_util
1717
from typing import Tuple
1818

1919
from instana.collector.helpers.runtime import (
@@ -226,9 +226,15 @@ def _start_profiler() -> None:
226226
profiler.start()
227227

228228

229-
if "INSTANA_DISABLE" not in os.environ and not is_truthy(
230-
os.environ.get("INSTANA_TRACING_DISABLE", None)
231-
):
229+
if "INSTANA_DISABLE" in os.environ: # pragma: no cover
230+
import warnings
231+
232+
message = "Instana: The INSTANA_DISABLE environment variable is deprecated. Please use INSTANA_TRACING_DISABLE=True instead."
233+
warnings.simplefilter("always")
234+
warnings.warn(message, DeprecationWarning)
235+
236+
237+
if not is_truthy(os.environ.get("INSTANA_TRACING_DISABLE", None)):
232238
# There are cases when sys.argv may not be defined at load time. Seems to happen in embedded Python,
233239
# and some Pipenv installs. If this is the case, it's best effort.
234240
if (
@@ -246,7 +252,7 @@ def _start_profiler() -> None:
246252
if (
247253
(is_autowrapt_instrumented() or is_webhook_instrumented())
248254
and "INSTANA_DISABLE_AUTO_INSTR" not in os.environ
249-
and importlib.util.find_spec("gevent")
255+
and importlib_util.find_spec("gevent")
250256
):
251257
apply_gevent_monkey_patch()
252258

0 commit comments

Comments
 (0)