Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IOPIPE_TRACE_AUTO_HTTP_ENABLED env var logic #332

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions iopipe/contrib/trace/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions tests/contrib/trace/test_plugin.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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