Пример #1
0
    def test_create_service_defaults(self, monkeypatch):
        datadog_obj = pretend.stub()
        datadog_cls = pretend.call_recorder(lambda **kw: datadog_obj)

        monkeypatch.setattr(services, "DogStatsd", datadog_cls)

        context = pretend.stub()
        request = pretend.stub(registry=pretend.stub(settings={}))

        metrics = DataDogMetrics.create_service(context, request)

        assert metrics._datadog is datadog_obj
        assert datadog_cls.calls == [
            pretend.call(host="127.0.0.1", port=8125, namespace=None, use_ms=True)
        ]
Пример #2
0
    def test_create_service_overrides(self, monkeypatch):
        datadog_obj = pretend.stub()
        datadog_cls = pretend.call_recorder(lambda **kw: datadog_obj)

        monkeypatch.setattr(services, "DogStatsd", datadog_cls)

        context = pretend.stub()
        request = pretend.stub(
            registry=pretend.stub(
                settings={
                    "metrics.host": "example.com",
                    "metrics.port": "9152",
                    "metrics.namespace": "thing",
                }
            )
        )

        metrics = DataDogMetrics.create_service(context, request)

        assert metrics._datadog is datadog_obj
        assert datadog_cls.calls == [
            pretend.call(host="example.com", port=9152, namespace="thing", use_ms=True)
        ]