-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: reduce snowplow telemetry timeout from 5s to 1s #12741
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
Open
claygeo
wants to merge
3
commits into
dbt-labs:main
Choose a base branch
from
claygeo:fix/snowplow-quick-connection-timeout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
−2
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: Fixes | ||
| body: Reduce snowplow telemetry HTTP timeout from 5s to 1s so an unreachable collector does not stall dbt at the end of every invocation | ||
| time: 2026-03-29T19:00:00.000000-04:00 | ||
| custom: | ||
| Author: claygeo | ||
| Issue: "9989" |
6 changes: 6 additions & 0 deletions
6
.changes/unreleased/Fixes-20260330-152707-snowplow_quick_connection_timeout.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: Fixes | ||
| body: "Reduce snowplow telemetry connection timeout from 5s to 1s" | ||
| time: 2026-03-30T15:27:05.000000+00:00 | ||
| custom: | ||
| Author: claygeo | ||
| Issue: "12741" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,10 @@ def http_post(self, payload): | |
| self.endpoint, | ||
| data=payload, | ||
| headers={"content-type": "application/json; charset=utf-8"}, | ||
| timeout=5.0, | ||
| # Keep the timeout short so that a missing or unreachable collector | ||
| # does not noticeably delay the end of every dbt invocation. | ||
| # See https://github.com/dbt-labs/dbt-core/issues/9989 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| timeout=1.0, | ||
| ) | ||
|
|
||
| self._log_result("GET", r.status_code) | ||
|
|
@@ -109,7 +112,14 @@ def http_post(self, payload): | |
| def http_get(self, payload): | ||
| self._log_request("GET", payload) | ||
|
|
||
| r = requests.get(self.endpoint, params=payload, timeout=5.0) | ||
| r = requests.get( | ||
| self.endpoint, | ||
| params=payload, | ||
| # Keep the timeout short so that a missing or unreachable collector | ||
| # does not noticeably delay the end of every dbt invocation. | ||
| # See https://github.com/dbt-labs/dbt-core/issues/9989 | ||
| timeout=1.0, | ||
| ) | ||
|
|
||
| self._log_result("GET", r.status_code) | ||
| return r | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import datetime | ||
| import tempfile | ||
| from unittest import mock | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
|
|
@@ -89,6 +90,7 @@ def test_initialize_from_flags(self, tempdir, send_anonymous_usage_stats): | |
| assert dbt.tracking.active_user.do_not_track != send_anonymous_usage_stats | ||
|
|
||
|
|
||
| <<<<<<< HEAD | ||
|
||
| class TestCompileStatsTracking: | ||
| def test_generate_stats_includes_catalog_count(self) -> None: | ||
| mock_manifest = mock.MagicMock() | ||
|
|
@@ -228,3 +230,38 @@ def test_forwards_catalog_type_from_adapter_integration( | |
| opts = mock_track.call_args[0][0] | ||
| assert opts["catalog_type"] == "ICEBERG_REST" | ||
| adapter.get_catalog_integration.assert_called_once_with("test_catalog") | ||
|
|
||
|
|
||
| class TestTimeoutEmitter: | ||
| """Verify that the TimeoutEmitter uses short timeouts so an unreachable | ||
| collector doesn't stall dbt at the end of every invocation. | ||
| See https://github.com/dbt-labs/dbt-core/issues/9989 | ||
| """ | ||
|
|
||
| def test_http_post_uses_short_timeout(self): | ||
| emitter = dbt.tracking.TimeoutEmitter() | ||
| mock_response = MagicMock() | ||
| mock_response.status_code = 200 | ||
|
|
||
| with patch("dbt.tracking.requests.post", return_value=mock_response) as mock_post: | ||
| emitter.http_post('{"test": "payload"}') | ||
| _, kwargs = mock_post.call_args | ||
| assert "timeout" in kwargs | ||
| assert kwargs["timeout"] <= 2.0, ( | ||
| f"POST timeout {kwargs['timeout']}s is too long; keep it ≤ 2s so an unreachable " | ||
| "collector doesn't stall dbt at the end of every invocation." | ||
| ) | ||
|
|
||
| def test_http_get_uses_short_timeout(self): | ||
| emitter = dbt.tracking.TimeoutEmitter() | ||
| mock_response = MagicMock() | ||
| mock_response.status_code = 200 | ||
|
|
||
| with patch("dbt.tracking.requests.get", return_value=mock_response) as mock_get: | ||
| emitter.http_get({"test": "payload"}) | ||
| _, kwargs = mock_get.call_args | ||
| assert "timeout" in kwargs | ||
| assert kwargs["timeout"] <= 2.0, ( | ||
| f"GET timeout {kwargs['timeout']}s is too long; keep it ≤ 2s so an unreachable " | ||
| "collector doesn't stall dbt at the end of every invocation." | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changelog looks extraneous given the one above that references #9989