当前位置: 首页>>代码示例>>Python>>正文


Python DogStatsd.socket方法代码示例

本文整理汇总了Python中datadog.dogstatsd.base.DogStatsd.socket方法的典型用法代码示例。如果您正苦于以下问题:Python DogStatsd.socket方法的具体用法?Python DogStatsd.socket怎么用?Python DogStatsd.socket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datadog.dogstatsd.base.DogStatsd的用法示例。


在下文中一共展示了DogStatsd.socket方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tags_from_environment_and_constant

# 需要导入模块: from datadog.dogstatsd.base import DogStatsd [as 别名]
# 或者: from datadog.dogstatsd.base.DogStatsd import socket [as 别名]
 def test_tags_from_environment_and_constant(self):
     with preserve_environment_variable('DATADOG_TAGS'):
        os.environ['DATADOG_TAGS'] = 'country:china,age:45,blue'
        statsd = DogStatsd(constant_tags=['country:canada', 'red'])
     statsd.socket = FakeSocket()
     statsd.gauge('gt', 123.4)
     t.assert_equal('gt:123.4|g|#country:canada,red,country:china,age:45,blue', statsd.socket.recv())
开发者ID:dcrosta,项目名称:datadogpy,代码行数:9,代码来源:test_statsd.py

示例2: test_timing

# 需要导入模块: from datadog.dogstatsd.base import DogStatsd [as 别名]
# 或者: from datadog.dogstatsd.base.DogStatsd import socket [as 别名]
    def test_timing(self):
        """
        Timings can be submitted from concurrent threads.
        """
        # Create a DogStatsd client with a mocked socket
        statsd = DogStatsd()
        statsd.socket = self.socket

        # Samples
        values = set(range(10000))

        # Submit metrics from different threads
        self._submit_with_multiple_threads(statsd, "timing", values)

        # All metrics were properly submitted
        self.assertMetrics(values)
开发者ID:farmersbusinessnetwork,项目名称:datadogpy,代码行数:18,代码来源:test_statsd_thread_safety.py

示例3: test_decrement

# 需要导入模块: from datadog.dogstatsd.base import DogStatsd [as 别名]
# 或者: from datadog.dogstatsd.base.DogStatsd import socket [as 别名]
    def test_decrement(self):
        """
        Decrements can be submitted from concurrent threads.
        """
        # Create a DogStatsd client with a mocked socket
        statsd = DogStatsd()
        statsd.socket = self.socket

        # Samples
        values = set(range(10000))
        expected_value = set([-value for value in values])

        # Submit metrics from different threads
        self._submit_with_multiple_threads(statsd, "decrement", expected_value)

        #  All metrics were properly submitted
        self.assertMetrics(values)
开发者ID:farmersbusinessnetwork,项目名称:datadogpy,代码行数:19,代码来源:test_statsd_thread_safety.py

示例4: test_timed_context_manager_threaded

# 需要导入模块: from datadog.dogstatsd.base import DogStatsd [as 别名]
# 或者: from datadog.dogstatsd.base.DogStatsd import socket [as 别名]
    def test_timed_context_manager_threaded(self, mock_time):
        """
        `timed` context manager plays well with concurrent threads.
        """
        # Create a DogStatsd client with a mocked socket
        statsd = DogStatsd()
        statsd.socket = self.socket

        # Set up the mocked time
        mock_time.return_value = 0

        # Method to time
        def bar():
            """
            Wait 5 time units and return.
            """
            initial_time = mock_time.return_value

            with statsd.timed("foo"):
                while mock_time.return_value < initial_time + 2:
                    pass

        # Run the method within multiple threads
        threads = []
        for value in range(10):
            t = threading.Thread(target=bar)
            threads.append(t)
            # Bump time so that previous thread can complete
            mock_time.return_value += 1
            t.start()
            # Sleep to let the threads start
            time.sleep(0.1)

        # Bump time so that all threads completes
        time.sleep(0.1)
        mock_time.return_value += 1
        time.sleep(0.1)
        mock_time.return_value += 1

        for t in threads:
            t.join()

        # All metrics were properly submitted
        expected_values = [2 for _ in xrange(0, 10)]
        self.assertMetrics(expected_values)
开发者ID:farmersbusinessnetwork,项目名称:datadogpy,代码行数:47,代码来源:test_statsd_thread_safety.py

示例5: test_accessing_socket_multiple_times_returns_same_socket

# 需要导入模块: from datadog.dogstatsd.base import DogStatsd [as 别名]
# 或者: from datadog.dogstatsd.base.DogStatsd import socket [as 别名]
 def test_accessing_socket_multiple_times_returns_same_socket(self):
     dogpound = DogStatsd()
     fresh_socket = FakeSocket()
     dogpound.socket = fresh_socket
     t.assert_equal(fresh_socket, dogpound.get_socket())
     t.assert_not_equal(FakeSocket(), dogpound.get_socket())
开发者ID:dcrosta,项目名称:datadogpy,代码行数:8,代码来源:test_statsd.py


注:本文中的datadog.dogstatsd.base.DogStatsd.socket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。