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


C# Statsd.Send方法代碼示例

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


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

示例1: send_one_counter_and_one_timer_with_no_sample_rate_shows_in_commands

            public void send_one_counter_and_one_timer_with_no_sample_rate_shows_in_commands()
            {
                var s = new Statsd(new Statsd.Configuration() { Udp = _udp, RandomGenerator = _randomGenerator, StopwatchFactory = _stopwatch, Sender = _sender });
                s.Send<Counting>("counter", 1);
                s.Send<Timing>("timer", 1);

                IList<object[]> argsPerCall = _sender.GetArgumentsForCallsMadeOn(x => x.Send(Arg<Metric>.Is.Anything));
                Assert.That(argsPerCall.Count, Is.EqualTo(2));
                Assert.That(((Metric)argsPerCall[0][0]).Command, Is.EqualTo("counter:1|c"));
                Assert.That(((Metric)argsPerCall[1][0]).Command, Is.EqualTo("timer:1|ms"));
            }
開發者ID:Kyle2123,項目名稱:statsd-csharp-client,代碼行數:11,代碼來源:StatsdTests.cs

示例2: counting_exception_fails_silently

 public void counting_exception_fails_silently()
 {
     var s = new Statsd(_udp, _randomGenerator, _stopwatch);
     _udp.Stub(x => x.Send(Arg<string>.Is.Anything)).Throw(new Exception());
      s.Send<Statsd.Counting>("counter", 5);
     Assert.Pass();
 }
開發者ID:bilal-fazlani,項目名稱:statsd-csharp-client,代碼行數:7,代碼來源:StatsdTests.cs

示例3: timing_exception_fails_silently

 public void timing_exception_fails_silently()
 {
     _udp.Stub(x => x.Send(Arg<string>.Is.Anything)).Throw(new Exception());
     var s = new Statsd(_udp);
      s.Send<Statsd.Timing>("timer", 5);
     Assert.Pass();
 }
開發者ID:bilal-fazlani,項目名稱:statsd-csharp-client,代碼行數:7,代碼來源:StatsdTests.cs

示例4: 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

示例5: send_oversized_udp_packets_are_split_if_possible

        public void send_oversized_udp_packets_are_split_if_possible()
        {
            var msg = new String('f', MetricsConfig.DefaultStatsdMaxUDPPacketSize - 15);
            listenThread.Start(3); // Listen for 3 messages

            var sender = new BatchSender();
            var statsd = new Statsd(new Statsd.Configuration() { Udp = udp, Sender = sender });

            statsd.Send<Statsd.Counting>(msg, 1);
            statsd.Send<Statsd.Timing>(msg, 2);
            sender.Flush();

            // These two metrics should be split as their combined lengths exceed the maximum packet size
            AssertWasReceived(String.Format("{0}:1|c", msg), 0);
            AssertWasReceived(String.Format("{0}:2|ms", msg), 1);
            // No extra metric should be sent at the end
            AssertWasReceived(null, 2);
        }
開發者ID:Kyle2123,項目名稱:statsd-csharp-client,代碼行數:18,代碼來源:StatsdUDPTests.cs

示例6: 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

示例7: 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

示例8: 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

示例9: gauge_exception_fails_silently

 public void gauge_exception_fails_silently()
 {
     udp.Stub(x=>x.Send(Arg<string>.Is.Anything)).Throw(new Exception());
     Statsd s = new Statsd(udp);
     s.Send<Statsd.Gauge>("gauge", 5);
     Assert.Pass();
 }
開發者ID:raoulmillais,項目名稱:statsd-csharp-client,代碼行數:7,代碼來源:StatsdUnitTests.cs

示例10: set_max_udp_packet_size

 public void set_max_udp_packet_size()
 {
     // Make sure that we can set the max UDP packet size
     udp = new StatsdUDP(serverName, serverPort, 10);
     statsd = new Statsd(udp);
     var msg = new String('f', 5);
     listenThread.Start(2);
     statsd.Add<Statsd.Counting>(msg, 1);
     statsd.Add<Statsd.Timing>(msg, 2);
      statsd.Send();
     // Since our packet size limit is now 10, this (short) message should still be split
     AssertWasReceived(String.Format("{0}:1|c", msg), 0);
     AssertWasReceived(String.Format("{0}:2|ms", msg), 1);
 }
開發者ID:bilal-fazlani,項目名稱:statsd-csharp-client,代碼行數:14,代碼來源:StatsdUDPTests.cs

示例11: set_prefix_on_stats_name_when_calling_send

        public void set_prefix_on_stats_name_when_calling_send()
        {
            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch, "a.prefix.");
            s.Send<Statsd.Counting>("counter", 5);
            s.Send<Statsd.Counting>("counter", 5);

            udp.AssertWasCalled(x => x.Send("a.prefix.counter:5|c"), x => x.Repeat.Twice());
        }
開發者ID:AnthonySteele,項目名稱:statsd-csharp-client,代碼行數:8,代碼來源:StatsdUnitTests.cs

示例12: adds_gauge_with_large_double_values

 public void adds_gauge_with_large_double_values()
 {
     var s = new Statsd(_udp, _randomGenerator, _stopwatch);
     s.Send<Statsd.Gauge>("gauge", 34563478564785);
     _udp.AssertWasCalled(x => x.Send("gauge:34563478564785.000000000000000|g"));
 }
開發者ID:FrancisVarga,項目名稱:statsd-csharp-client,代碼行數:6,代碼來源:StatsdTests.cs

示例13: send_timer_with_lambda

        public void send_timer_with_lambda()
        {
            const string statName = "name";
            IStopwatch stopwatch = MockRepository.GenerateMock<IStopwatch>();
            stopwatch.Stub(x => x.ElapsedMilliseconds()).Return(500);
            _stopwatch.Stub(x => x.Get()).Return(stopwatch);

            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            s.Send(() => testMethod(), statName);

            udp.AssertWasCalled(x => x.Send("name:500|ms"));
        }
開發者ID:AnthonySteele,項目名稱:statsd-csharp-client,代碼行數:12,代碼來源:StatsdUnitTests.cs

示例14: set_return_value_with_send_timer_with_lambda

        public void set_return_value_with_send_timer_with_lambda()
        {
            const string statName = "name";
            IStopwatch stopwatch = MockRepository.GenerateMock<IStopwatch>();
            stopwatch.Stub(x => x.ElapsedMilliseconds()).Return(500);
            _stopwatch.Stub(x => x.Get()).Return(stopwatch);

            Statsd s = new Statsd(udp, _randomGenerator, _stopwatch);
            int returnValue = 0;
            s.Send(() => returnValue = testMethod(), statName);

            udp.AssertWasCalled(x => x.Send("name:500|ms" + Environment.NewLine));
            Assert.That(returnValue,Is.EqualTo(5));
        }
開發者ID:raoulmillais,項目名稱:statsd-csharp-client,代碼行數:14,代碼來源:StatsdUnitTests.cs

示例15: histrogram_exception_fails_silently

 public void histrogram_exception_fails_silently()
 {
     _udp.Stub(x => x.Send(Arg<string>.Is.Anything)).Throw(new Exception());
     var s = new Statsd(_udp);
     s.Send<Statsd.Histogram>("histogram", 5);
     Assert.Pass();
 }
開發者ID:FrancisVarga,項目名稱:statsd-csharp-client,代碼行數:7,代碼來源:StatsdTests.cs


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