diff --git a/iopipe/contrib/trace/plugin.py b/iopipe/contrib/trace/plugin.py index bfb64e0f..6e225fdf 100644 --- a/iopipe/contrib/trace/plugin.py +++ b/iopipe/contrib/trace/plugin.py @@ -31,9 +31,11 @@ def __init__( :type http_headers: list|tuple """ self.auto_measure = auto_measure - self.auto_http = auto_http is True or strtobool( - os.getenv("IOPIPE_TRACE_AUTO_HTTP_ENABLED", "false") - ) + self.auto_http = auto_http + if "IOPIPE_TRACE_AUTO_HTTP_ENABLED" in os.environ: + self.auto_http = bool( + strtobool(os.environ["IOPIPE_TRACE_AUTO_HTTP_ENABLED"]) + ) self.http_filter = http_filter self.http_headers = http_headers diff --git a/tests/contrib/trace/test_plugin.py b/tests/contrib/trace/test_plugin.py index f005d9bd..6c5def37 100644 --- a/tests/contrib/trace/test_plugin.py +++ b/tests/contrib/trace/test_plugin.py @@ -1,5 +1,8 @@ import mock +from iopipe import IOpipeCore +from iopipe.contrib.trace import TracePlugin + @mock.patch("iopipe.report.send_report", autospec=True) def test__trace_plugin(mock_send_report, handler_with_trace, mock_context): @@ -180,3 +183,11 @@ def test_trace_plugin__auto_http__filter_request( assert len(traces) == 1 assert "request" not in traces[0] assert "response" in traces[0] + + +def test__trace_plugin__auto_http__env_var(monkeypatch): + monkeypatch.setenv("IOPIPE_TRACE_AUTO_HTTP_ENABLED", "false") + + iopipe = IOpipeCore(plugins=[TracePlugin()]) + + assert iopipe.plugins[0].auto_http is False