當前位置: 首頁>>代碼示例>>C#>>正文


C# Statsd.Add方法代碼示例

本文整理匯總了C#中StatsdClient.Statsd.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# Statsd.Add方法的具體用法?C# Statsd.Add怎麽用?C# Statsd.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StatsdClient.Statsd的用法示例。


在下文中一共展示了Statsd.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: add_one_counter_and_one_gauge_sends_and_removes_commands

        public void add_one_counter_and_one_gauge_sends_and_removes_commands()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add("counter", 1, 0.1);
            s.Add<Statsd.Timing>("timer", 1);
            s.Send();

            Assert.That(s.Commands.Count,Is.EqualTo(0));
        }
開發者ID:raoulmillais,項目名稱:statsd-csharp-client,代碼行數:9,代碼來源:StatsdUnitTests.cs

示例2: add_one_counter_and_one_gauge_sends_in_one_go

        public void add_one_counter_and_one_gauge_sends_in_one_go()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add("counter", 1, 0.1);
            s.Add<Statsd.Timing>("timer", 1);
            s.Send();

            udp.AssertWasCalled(x => x.Send("counter:1|c|@0.1" + Environment.NewLine + "timer:1|ms" + Environment.NewLine));
        }
開發者ID:raoulmillais,項目名稱:statsd-csharp-client,代碼行數:9,代碼來源:StatsdUnitTests.cs

示例3: add_counter_sets_prefix_on_name

        public void add_counter_sets_prefix_on_name()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch, "another.prefix.");

            s.Add<Statsd.Counting,int>("counter", 1, sampleRate: 0.1);
            s.Add<Statsd.Timing,int>("timer", 1);
            s.Send();

            udp.AssertWasCalled(x => x.Send("another.prefix.counter:1|c|@0.1\nanother.prefix.timer:1|ms"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:10,代碼來源:StatsdUnitTests.cs

示例4: add_counter_sets_prefix_on_name

        public void add_counter_sets_prefix_on_name()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch, "another.prefix.");

            s.Add("counter", 1, 0.1);
            s.Add<Statsd.Timing>("timer", 1);
            s.Send();

            udp.AssertWasCalled(x => x.Send("another.prefix.counter:1|c|@0.1" + Environment.NewLine + "another.prefix.timer:1|ms"));
        }
開發者ID:AnthonySteele,項目名稱:statsd-csharp-client,代碼行數:10,代碼來源:StatsdUnitTests.cs

示例5: add_one_counter_and_one_gauge_shows_in_commands

            public void add_one_counter_and_one_gauge_shows_in_commands()
            {
                var s = new Statsd(_udp, _randomGenerator, _stopwatch);
                s.Add<Statsd.Counting>("counter", 1, 0.1);
                s.Add<Statsd.Timing>("timer", 1);

                Assert.That(s.Commands.Count, Is.EqualTo(2));
                Assert.That(s.Commands[0], Is.EqualTo("counter:1|c|@0.1"));
                Assert.That(s.Commands[1], Is.EqualTo("timer:1|ms"));
            }
開發者ID:FrancisVarga,項目名稱:statsd-csharp-client,代碼行數:10,代碼來源:StatsdTests.cs

示例6: add_one_counter_and_one_gauge_with_no_sample_rate_shows_in_commands

        public void add_one_counter_and_one_gauge_with_no_sample_rate_shows_in_commands()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Counting>("counter", 1);
            s.Add<Statsd.Timing>("timer", 1);

            Assert.That(s.Commands.Count, Is.EqualTo(2));
            Assert.That(s.Commands[0], Is.EqualTo("counter:1|c"));
            Assert.That(s.Commands[1], Is.EqualTo("timer:1|ms"));
        }
開發者ID:raoulmillais,項目名稱:statsd-csharp-client,代碼行數:10,代碼來源:StatsdUnitTests.cs

示例7: add_gauge_double

        public void add_gauge_double()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Gauge,double>("gauge", 5.3);

            Assert.That(s.Commands.Count, Is.EqualTo(1));
            Assert.That(s.Commands[0], Is.EqualTo("gauge:5.3|g"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs

示例8: add_gauge_with_sample_rate

        public void add_gauge_with_sample_rate()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Gauge,int>("gauge", 5, sampleRate: 0.5);

            Assert.That(s.Commands.Count, Is.EqualTo(1));
            Assert.That(s.Commands[0], Is.EqualTo("gauge:5|g|@0.5"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs

示例9: add_gauge_with_sample_rate_and_tags_double

        public void add_gauge_with_sample_rate_and_tags_double()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Gauge,int>("gauge", 5, sampleRate: 0.5, tags: new[] {"tag1:true", "tag2"});

            Assert.That(s.Commands.Count, Is.EqualTo(1));
            Assert.That(s.Commands[0], Is.EqualTo("gauge:5|g|@0.5|#tag1:true,tag2"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs

示例10: add_one_counter_and_one_timer_sends_in_one_go

            public void add_one_counter_and_one_timer_sends_in_one_go()
            {
                var s = new Statsd(_udp, _randomGenerator, _stopwatch);
                s.Add<Statsd.Counting>("counter", 1, 0.1);
                s.Add<Statsd.Timing>("timer", 1);
                s.Send();

                _udp.AssertWasCalled(x => x.Send("counter:1|c|@0.1\ntimer:1|ms"));
            }
開發者ID:FrancisVarga,項目名稱:statsd-csharp-client,代碼行數:9,代碼來源:StatsdTests.cs

示例11: add_one_counter_and_send_one_gauge_sends_only_sends_the_last_and_clears_queue

        public void add_one_counter_and_send_one_gauge_sends_only_sends_the_last_and_clears_queue()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Counting,int>("counter", 1);
            s.Send<Statsd.Timing,int>("timer", 1);

            udp.AssertWasCalled(x => x.Send("timer:1|ms"));

            s.Send();

            udp.AssertWasNotCalled(x => x.Send("counter:1|c"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:12,代碼來源:StatsdUnitTests.cs

示例12: add_timer_with_lamba_still_records_on_error_and_still_bubbles_up_exception

        public void add_timer_with_lamba_still_records_on_error_and_still_bubbles_up_exception()
        {
            const string statName = "name";

            var stopwatch = MockRepository.GenerateMock<IStopwatch>();
            stopwatch.Stub(x => x.ElapsedMilliseconds()).Return(500);
            _stopwatch.Stub(x => x.Get()).Return(stopwatch);

            var s = new Statsd(udp, _randomGenerator, _stopwatch);

            Assert.Throws<InvalidOperationException>(() => s.Add(() => { throw new InvalidOperationException(); }, statName));

            Assert.That(s.Commands.Count, Is.EqualTo(1));
            Assert.That(s.Commands[0], Is.EqualTo("name:500|ms"));
        }
開發者ID:AnthonySteele,項目名稱:statsd-csharp-client,代碼行數:15,代碼來源:StatsdUnitTests.cs

示例13: add_one_counter_and_send_one_gauge_sends_only_sends_the_last_two_doubles

        public void add_one_counter_and_send_one_gauge_sends_only_sends_the_last_two_doubles()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Counting,double>("counter", 1.1);
            s.Send<Statsd.Timing,double>("timer", 1.1);

            udp.AssertWasCalled(x => x.Send("timer:1.1|ms"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs

示例14: add_timer_with_lamba_and_sampleRate_passes

            public void add_timer_with_lamba_and_sampleRate_passes()
            {
                const string statName = "name";

                var stopwatch = MockRepository.GenerateMock<IStopwatch>();
                stopwatch.Stub(x => x.ElapsedMilliseconds()).Return(500);
                _stopwatch.Stub(x => x.Get()).Return(stopwatch);
                _randomGenerator = MockRepository.GenerateMock<IRandomGenerator>();
                _randomGenerator.Stub(x => x.ShouldSend(Arg<double>.Is.Anything)).Return(true);

                var s = new Statsd(_udp, _randomGenerator, _stopwatch);
                s.Add(() => TestMethod(), statName, 0.1);

                Assert.That(s.Commands.Count, Is.EqualTo(1));
                Assert.That(s.Commands[0], Is.EqualTo("name:500|ms"));
            }
開發者ID:FrancisVarga,項目名稱:statsd-csharp-client,代碼行數:16,代碼來源:StatsdTests.cs

示例15: add_set_string

        public void add_set_string()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Add<Statsd.Set,string>("set", "string");

            Assert.That(s.Commands.Count, Is.EqualTo(1));
            Assert.That(s.Commands[0], Is.EqualTo("set:string|s"));
        }
開發者ID:kjgorman,項目名稱:dogstatsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs


注:本文中的StatsdClient.Statsd.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。