def test_call_end_twice(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', ) should_collect.return_value = False client.begin_transaction() client.end_transaction(200, 'test-transaction') client.end_transaction(200, 'test-transaction')
def test_call_end_twice(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', ) should_collect.return_value = False client.begin_transaction("celery") client.end_transaction(200, 'test-transaction') client.end_transaction(200, 'test-transaction')
def test_ignore_patterns(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', async_mode=True, transactions_ignore_patterns=['^OPTIONS', 'views.api.v2']) should_collect.return_value = False client.begin_transaction("web") client.end_transaction('OPTIONS views.healthcheck', 200) client.begin_transaction("web") client.end_transaction('GET views.users', 200) self.assertEqual(len(client.instrumentation_store), 1)
def test_metrics_collection(self, should_collect, mock_send): client = Client( servers=["http://example.com"], organization_id="organization_id", app_id="app_id", secret_token="secret" ) should_collect.return_value = False for i in range(7): client.begin_transaction("transaction.test") client.end_transaction("test-transaction", 200) self.assertEqual(len(client.instrumentation_store), 7) self.assertEqual(mock_send.call_count, 0) should_collect.return_value = True client.begin_transaction("transaction.test") client.end_transaction("my-other-transaction", 200) self.assertEqual(len(client.instrumentation_store), 0) self.assertEqual(mock_send.call_count, 1)
def test_ignore_patterns(self, should_collect, mock_send): client = Client( servers=["http://example.com"], organization_id="organization_id", app_id="app_id", secret_token="secret", async_mode=True, transactions_ignore_patterns=["^OPTIONS", "views.api.v2"], ) should_collect.return_value = False client.begin_transaction("web") client.end_transaction("OPTIONS views.healthcheck", 200) client.begin_transaction("web") client.end_transaction("GET views.users", 200) self.assertEqual(len(client.instrumentation_store), 1)
def test_metrics_collection(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', ) should_collect.return_value = False for i in range(7): client.begin_transaction() client.end_transaction(200, 'test-transaction') self.assertEqual(len(client.instrumentation_store), 7) self.assertEqual(mock_send.call_count, 0) should_collect.return_value = True client.begin_transaction() client.end_transaction(200, 'my-other-transaction') self.assertEqual(len(client.instrumentation_store), 0) self.assertEqual(mock_send.call_count, 1)
def test_metrics_collection(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', ) should_collect.return_value = False for i in range(7): client.begin_transaction("transaction.test") client.end_transaction('test-transaction', 200) self.assertEqual(len(client.instrumentation_store), 7) self.assertEqual(mock_send.call_count, 0) should_collect.return_value = True client.begin_transaction("transaction.test") client.end_transaction('my-other-transaction', 200) self.assertEqual(len(client.instrumentation_store), 0) self.assertEqual(mock_send.call_count, 1)
def test_ignore_patterns(self, should_collect, mock_send): client = Client( servers=['http://example.com'], organization_id='organization_id', app_id='app_id', secret_token='secret', async_mode=True, transactions_ignore_patterns=[ '^OPTIONS', 'views.api.v2' ] ) should_collect.return_value = False client.begin_transaction("web") client.end_transaction('OPTIONS views.healthcheck', 200) client.begin_transaction("web") client.end_transaction('GET views.users', 200) self.assertEqual(len(client.instrumentation_store), 1)