{"action":"created","comment":{"url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/comments/85803677","pull_request_review_id":6497829,"id":85803677,"diff_hunk":"@@ -116,13 +123,72 @@ def test_rate_limiting_sampler():\n         for i in range(0, 3):\n             sampled, tags = sampler.is_sampled(0)\n             assert not sampled, 'but no further, since time is stopped'\n-        assert tags == {\n-            'sampler.type': 'ratelimiting',\n-            'sampler.param': 2,\n-        }\n+        assert tags == get_tags('ratelimiting', 2)\n     sampler.close()\n     assert '%s' % sampler == 'RateLimitingSampler(2)'\n \n+    # Test with rate limit of less than 1 second\n+    sampler = RateLimitingSampler(0.1)\n+    ts = time.time()\n+    sampler.last_tick = ts\n+    with mock.patch('jaeger_client.sampler.RateLimitingSampler.timestamp') \\\n+            as mock_time:\n+        mock_time.side_effect = lambda: ts  # always return same time\n+        assert sampler.timestamp() == ts\n+        sampled, _ = sampler.is_sampled(0)\n+        assert not sampled\n+\n+        # move time 110ms forward, enough credits to pay for one sample\n+        mock_time.side_effect = lambda: ts + 0.11\n+        assert sampler.is_sampled(0)\n+    sampler.close()\n+    assert '%s' % sampler == 'RateLimitingSampler(0.1)'\n+\n+\n+def test_guaranteed_throughput_probabilistic_sampler():\n+    sampler = GuaranteedThroughputProbabilisticSampler('op', 2, 0.5)\n+    id1 = 1L << 63  # second most significant bit, dividing full range in half\n+    assert id1 == 0x8000000000000000L\n+    sampled, tags = sampler.is_sampled(id1-10)\n+    assert sampled\n+    assert tags == get_tags('probabilistic', 0.5)\n+    sampled, tags = sampler.is_sampled(id1+10)\n+    assert sampled\n+    assert tags == get_tags('lowerbound', 0.5)\n+    sampled, _ = sampler.is_sampled(id1+10)\n+    assert not sampled\n+\n+    sampler.close()\n+    assert '%s' % sampler == 'GuaranteedThroughputProbabilisticSampler(op, 0.5, 2)'\n+\n+\n+def test_adaptive_sampler():\n+    sampling_rates = [\n+        OperationSamplingStrategy('op', ProbabilisticSamplingStrategy(0.5))\n+    ]\n+    strategies = PerOperationSamplingStrategies(0.51, 3, sampling_rates)\n+\n+    sampler = AdaptiveSampler(strategies, 2)\n+    id1 = 1L << 63  # second most significant bit, dividing full range in half\n+    assert id1 == 0x8000000000000000L","path":"tests/test_sampler.py","position":102,"original_position":102,"commit_id":"21221da9b292f18c08e5f3639f15107e6027bfef","original_commit_id":"21221da9b292f18c08e5f3639f15107e6027bfef","user":{"login":"yurishkuro","id":3523016,"avatar_url":"https://avatars.githubusercontent.com/u/3523016?v=3","gravatar_id":"","url":"https://api.github.com/users/yurishkuro","html_url":"https://github.com/yurishkuro","followers_url":"https://api.github.com/users/yurishkuro/followers","following_url":"https://api.github.com/users/yurishkuro/following{/other_user}","gists_url":"https://api.github.com/users/yurishkuro/gists{/gist_id}","starred_url":"https://api.github.com/users/yurishkuro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurishkuro/subscriptions","organizations_url":"https://api.github.com/users/yurishkuro/orgs","repos_url":"https://api.github.com/users/yurishkuro/repos","events_url":"https://api.github.com/users/yurishkuro/events{/privacy}","received_events_url":"https://api.github.com/users/yurishkuro/received_events","type":"User","site_admin":false},"body":"we keep doing this, let's define  constant once and have a standalone test that validates that the constant is equal to `1L << 63` expression","created_at":"2016-10-31T18:33:06Z","updated_at":"2016-10-31T18:33:06Z","html_url":"https://github.com/uber/jaeger-client-python/pull/25#discussion_r85803677","pull_request_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/comments/85803677"},"html":{"href":"https://github.com/uber/jaeger-client-python/pull/25#discussion_r85803677"},"pull_request":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25","id":91650859,"html_url":"https://github.com/uber/jaeger-client-python/pull/25","diff_url":"https://github.com/uber/jaeger-client-python/pull/25.diff","patch_url":"https://github.com/uber/jaeger-client-python/pull/25.patch","issue_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/25","number":25,"state":"open","locked":false,"title":"Add Adaptive Sampler","user":{"login":"black-adder","id":791791,"avatar_url":"https://avatars.githubusercontent.com/u/791791?v=3","gravatar_id":"","url":"https://api.github.com/users/black-adder","html_url":"https://github.com/black-adder","followers_url":"https://api.github.com/users/black-adder/followers","following_url":"https://api.github.com/users/black-adder/following{/other_user}","gists_url":"https://api.github.com/users/black-adder/gists{/gist_id}","starred_url":"https://api.github.com/users/black-adder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/black-adder/subscriptions","organizations_url":"https://api.github.com/users/black-adder/orgs","repos_url":"https://api.github.com/users/black-adder/repos","events_url":"https://api.github.com/users/black-adder/events{/privacy}","received_events_url":"https://api.github.com/users/black-adder/received_events","type":"User","site_admin":false},"body":"- [x] Tests\r\n\r\nThis PR doesn't include initializing and updating the adaptive sampler. I'll do that in a subsequent PR.","created_at":"2016-10-31T17:17:04Z","updated_at":"2016-10-31T18:33:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a773dd4ed336e28e5fc814528025e9d92946fd3c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25/commits","review_comments_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25/comments","review_comment_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/25/comments","statuses_url":"https://api.github.com/repos/uber/jaeger-client-python/statuses/21221da9b292f18c08e5f3639f15107e6027bfef","head":{"label":"uber:add_adaptive_sampler","ref":"add_adaptive_sampler","sha":"21221da9b292f18c08e5f3639f15107e6027bfef","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":56551019,"name":"jaeger-client-python","full_name":"uber/jaeger-client-python","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/jaeger-client-python","description":"Jaeger Bindings for Python OpenTracing API","fork":false,"url":"https://api.github.com/repos/uber/jaeger-client-python","forks_url":"https://api.github.com/repos/uber/jaeger-client-python/forks","keys_url":"https://api.github.com/repos/uber/jaeger-client-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/jaeger-client-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/jaeger-client-python/teams","hooks_url":"https://api.github.com/repos/uber/jaeger-client-python/hooks","issue_events_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/events{/number}","events_url":"https://api.github.com/repos/uber/jaeger-client-python/events","assignees_url":"https://api.github.com/repos/uber/jaeger-client-python/assignees{/user}","branches_url":"https://api.github.com/repos/uber/jaeger-client-python/branches{/branch}","tags_url":"https://api.github.com/repos/uber/jaeger-client-python/tags","blobs_url":"https://api.github.com/repos/uber/jaeger-client-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/jaeger-client-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/jaeger-client-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/jaeger-client-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/jaeger-client-python/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/jaeger-client-python/languages","stargazers_url":"https://api.github.com/repos/uber/jaeger-client-python/stargazers","contributors_url":"https://api.github.com/repos/uber/jaeger-client-python/contributors","subscribers_url":"https://api.github.com/repos/uber/jaeger-client-python/subscribers","subscription_url":"https://api.github.com/repos/uber/jaeger-client-python/subscription","commits_url":"https://api.github.com/repos/uber/jaeger-client-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/jaeger-client-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/jaeger-client-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/jaeger-client-python/contents/{+path}","compare_url":"https://api.github.com/repos/uber/jaeger-client-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/jaeger-client-python/merges","archive_url":"https://api.github.com/repos/uber/jaeger-client-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/jaeger-client-python/downloads","issues_url":"https://api.github.com/repos/uber/jaeger-client-python/issues{/number}","pulls_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/jaeger-client-python/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/jaeger-client-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/jaeger-client-python/labels{/name}","releases_url":"https://api.github.com/repos/uber/jaeger-client-python/releases{/id}","deployments_url":"https://api.github.com/repos/uber/jaeger-client-python/deployments","created_at":"2016-04-19T00:10:38Z","updated_at":"2016-10-25T21:31:27Z","pushed_at":"2016-10-31T18:25:21Z","git_url":"git://github.com/uber/jaeger-client-python.git","ssh_url":"git@github.com:uber/jaeger-client-python.git","clone_url":"https://github.com/uber/jaeger-client-python.git","svn_url":"https://github.com/uber/jaeger-client-python","homepage":"","size":202,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":5,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"ce740a821a1ed4423c9e5f210407461bec0c888c","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":56551019,"name":"jaeger-client-python","full_name":"uber/jaeger-client-python","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/jaeger-client-python","description":"Jaeger Bindings for Python OpenTracing API","fork":false,"url":"https://api.github.com/repos/uber/jaeger-client-python","forks_url":"https://api.github.com/repos/uber/jaeger-client-python/forks","keys_url":"https://api.github.com/repos/uber/jaeger-client-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/jaeger-client-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/jaeger-client-python/teams","hooks_url":"https://api.github.com/repos/uber/jaeger-client-python/hooks","issue_events_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/events{/number}","events_url":"https://api.github.com/repos/uber/jaeger-client-python/events","assignees_url":"https://api.github.com/repos/uber/jaeger-client-python/assignees{/user}","branches_url":"https://api.github.com/repos/uber/jaeger-client-python/branches{/branch}","tags_url":"https://api.github.com/repos/uber/jaeger-client-python/tags","blobs_url":"https://api.github.com/repos/uber/jaeger-client-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/jaeger-client-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/jaeger-client-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/jaeger-client-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/jaeger-client-python/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/jaeger-client-python/languages","stargazers_url":"https://api.github.com/repos/uber/jaeger-client-python/stargazers","contributors_url":"https://api.github.com/repos/uber/jaeger-client-python/contributors","subscribers_url":"https://api.github.com/repos/uber/jaeger-client-python/subscribers","subscription_url":"https://api.github.com/repos/uber/jaeger-client-python/subscription","commits_url":"https://api.github.com/repos/uber/jaeger-client-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/jaeger-client-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/jaeger-client-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/jaeger-client-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/jaeger-client-python/contents/{+path}","compare_url":"https://api.github.com/repos/uber/jaeger-client-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/jaeger-client-python/merges","archive_url":"https://api.github.com/repos/uber/jaeger-client-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/jaeger-client-python/downloads","issues_url":"https://api.github.com/repos/uber/jaeger-client-python/issues{/number}","pulls_url":"https://api.github.com/repos/uber/jaeger-client-python/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/jaeger-client-python/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/jaeger-client-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/jaeger-client-python/labels{/name}","releases_url":"https://api.github.com/repos/uber/jaeger-client-python/releases{/id}","deployments_url":"https://api.github.com/repos/uber/jaeger-client-python/deployments","created_at":"2016-04-19T00:10:38Z","updated_at":"2016-10-25T21:31:27Z","pushed_at":"2016-10-31T18:25:21Z","git_url":"git://github.com/uber/jaeger-client-python.git","ssh_url":"git@github.com:uber/jaeger-client-python.git","clone_url":"https://github.com/uber/jaeger-client-python.git","svn_url":"https://github.com/uber/jaeger-client-python","homepage":"","size":202,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25"},"html":{"href":"https://github.com/uber/jaeger-client-python/pull/25"},"issue":{"href":"https://api.github.com/repos/uber/jaeger-client-python/issues/25"},"comments":{"href":"https://api.github.com/repos/uber/jaeger-client-python/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/jaeger-client-python/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/uber/jaeger-client-python/statuses/21221da9b292f18c08e5f3639f15107e6027bfef"}}}}
{"actor":{"display_login":"yurishkuro"}}