-
Notifications
You must be signed in to change notification settings - Fork 182
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
improves trackers thread pool #1340
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9233708
adds mandatory prefix to managed pool
rudolfix 2d31a39
starts and stops pools on init, not lazy
rudolfix 0c08ed6
simplifies at_exit, adds end2end anon telemetry test
rudolfix 21dd8a8
fixes platform test
rudolfix f616bc9
skips windows forked tests
rudolfix 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
import base64 | ||
from unittest.mock import patch | ||
|
||
from pytest_mock import MockerFixture | ||
|
||
from dlt.common import logger | ||
from dlt.common.runtime.anon_tracker import get_anonymous_id, track, disable_anon_tracker | ||
from dlt.common.typing import DictStrAny, DictStrStr | ||
|
@@ -30,7 +32,7 @@ class SentryLoggerConfiguration(RunConfiguration): | |
sentry_dsn: str = ( | ||
"https://[email protected]/4504819859914752" | ||
) | ||
dlthub_telemetry_segment_write_key: str = "TLJiyRkGVZGCi2TtjClamXpFcxAA1rSB" | ||
# dlthub_telemetry_segment_write_key: str = "TLJiyRkGVZGCi2TtjClamXpFcxAA1rSB" | ||
|
||
|
||
@configspec | ||
|
@@ -133,17 +135,34 @@ def test_sentry_init(environment: DictStrStr) -> None: | |
|
||
|
||
@pytest.mark.forked | ||
def test_track_anon_event() -> None: | ||
def test_track_anon_event(mocker: MockerFixture) -> None: | ||
from dlt.sources.helpers import requests | ||
from dlt.common.runtime import anon_tracker | ||
|
||
mock_github_env(os.environ) | ||
mock_pod_env(os.environ) | ||
config = SentryLoggerConfiguration() | ||
|
||
requests_post = mocker.spy(requests, "post") | ||
|
||
props = {"destination_name": "duckdb", "elapsed_time": 712.23123, "success": True} | ||
with patch("dlt.common.runtime.anon_tracker.before_send", _mock_before_send): | ||
start_test_telemetry(SentryLoggerConfiguration()) | ||
start_test_telemetry(config) | ||
track("pipeline", "run", props) | ||
# this will send stuff | ||
disable_anon_tracker() | ||
|
||
event = SENT_ITEMS[0] | ||
# requests were really called | ||
requests_post.assert_called_once_with( | ||
config.dlthub_telemetry_endpoint, | ||
headers=anon_tracker._tracker_request_header(None), | ||
json=event, | ||
timeout=anon_tracker._REQUEST_TIMEOUT, | ||
) | ||
# was actually delivered | ||
assert requests_post.spy_return.status_code == 204 | ||
|
||
assert event["anonymousId"] == get_anonymous_id() | ||
assert event["event"] == "pipeline_run" | ||
assert props.items() <= event["properties"].items() | ||
|
This file contains 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
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.
why do we need to skip these tests on windows?
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.
because they are run in fork and that is not available on windows. the test is messing up with global objects