• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StatsdClient.Statsd类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中StatsdClient.Statsd的典型用法代码示例。如果您正苦于以下问题:C# Statsd类的具体用法?C# Statsd怎么用?C# Statsd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Statsd类属于StatsdClient命名空间,在下文中一共展示了Statsd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

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


示例2: ListenerService

        public ListenerService()
        {
            InitializeComponent();
            
            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            EventLog.Log = "HubCollectorLog";
            StatsdClient = new Statsd(Config.Hostname, Config.Port);
            KlondikeConnections = new List<HubConnection>();

            Config.Hubs.ForEach(hub =>
            {
                var connection = new HubConnection(hub);

                IHubProxy statusHubProxy = connection.CreateHubProxy("status");
                statusHubProxy.On("updateStatus", status =>
                {
                    string name = Config.NameFromUrl(connection.Url);
                    var message = String.Format("From {2}: Status: {0}, Total: {1}", status.synchronizationState,
                        status.totalPackages, name);
                    EventLog.WriteEntry(message);
                    //Console.WriteLine(message);

                    StatsdClient.LogGauge("nuget."+ name +".packageCount", (int) status.totalPackages);
                });

                KlondikeConnections.Add(connection);
            });
        }
开发者ID:plukevdh,项目名称:signalr_service_demo,代码行数:28,代码来源:ListenerService.cs


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


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


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


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


示例7: SetUpUdpListenerAndStatsd

 public void SetUpUdpListenerAndStatsd() 
 {
     udpListener = new UdpListener(serverName, serverPort);
     var metricsConfig = new MetricsConfig { StatsdServerName = serverName };
     StatsdClient.Metrics.Configure(metricsConfig);
     udp = new StatsdUDP(serverName, serverPort);
     statsd = new Statsd(udp);
 }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client,代码行数:8,代码来源:StatsdUDPTests.cs


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


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


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


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


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


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


示例14: DatadogSink

        /// <summary>
        /// Construct a sink that uses datadog with the specified details.
        /// </summary>
        /// <param name="datadogConfiguration">Connection information used to construct the Datadog client.</param>
        /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="textFormatter">Supplies culture-specific formatting information, or null.</param>
        public DatadogSink(DatadogConfiguration datadogConfiguration, int batchSizeLimit, TimeSpan period, ITextFormatter textFormatter)
            : base(batchSizeLimit, period)
        {
            if (datadogConfiguration == null) throw new ArgumentNullException("datadogConfiguration");

            _datadogConfiguration = datadogConfiguration;
            _textFormatter = textFormatter;
            _statsdUdp = new StatsdUDP(datadogConfiguration.StatsdServer, datadogConfiguration.StatsdPort);
            _statsd = new Statsd(_statsdUdp);
        }
开发者ID:Applicita,项目名称:serilog-sinks-datadog,代码行数:17,代码来源:DatadogSink.cs


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


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


示例17: Main

    static void Main(string[] args)
    {
      var options = new Options();
      if (CommandLine.Parser.Default.ParseArgumentsStrict(args, options))
      {
        var client = new Statsd(options.Host, options.Port, prefix : options.Namespace, connectionType : options.UseTCP ? ConnectionType.Tcp : ConnectionType.Udp);
        var tokenSource = new System.Threading.CancellationTokenSource();
        var stopwatch = Stopwatch.StartNew();
        var totalMetricsSent = 0;
        var tasks = new List<Task>();
        int numThreads = options.Threads == 0 ? 1 : options.Threads;
        for ( int count = 0; count < numThreads; count++ )
        {
          int myTaskNumber = count;
          var task = Task.Factory.StartNew( () =>
            {
              var rnd = new Random();
              int taskNumber = myTaskNumber;
              if ( taskNumber == 0 )
              {
                Console.WriteLine( "Feeding stats to {0}:{1}, ctrl+c to exit.", options.Host, options.Port );
              }
              while ( true )
              {
                client.LogCount( "test.count.one." + rnd.Next( 5 ) );
                client.LogCount( "test.count.bigValue", rnd.Next( 50 ) );
                client.LogTiming( "test.timing." + rnd.Next( 5 ), rnd.Next( 100, 2000 ) );
                client.LogGauge( "test.gauge." + rnd.Next( 5 ), rnd.Next( 100 ) );
                Thread.Sleep( options.Delay );
                Interlocked.Add( ref totalMetricsSent, 4 );

                if ( taskNumber == 0 && stopwatch.ElapsedMilliseconds >= 5000 )
                {
                  Console.WriteLine( "Total sent: {0}", totalMetricsSent );
                  stopwatch.Restart();
                }
              }
            },
            tokenSource.Token );
          tasks.Add( task );
        }
        Console.CancelKeyPress += (sender, e) =>
          {
            tokenSource.Cancel();
          };
        Task.WaitAll( tasks.ToArray() );
      }
    }
开发者ID:joshclark,项目名称:statsd.net,代码行数:48,代码来源:Program.cs


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


示例19: send_oversized_udp_packets_are_split_if_possible_with_multiple_messages_in_one_packet

        public void send_oversized_udp_packets_are_split_if_possible_with_multiple_messages_in_one_packet()
        {
            var msg = new String('f', MetricsConfig.DefaultStatsdMaxUDPPacketSize / 2);
            listenThread.Start(3);

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

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

            // Make sure that a split packet can contain mulitple metrics
            AssertWasReceived(String.Format("counter:1|c\n{0}:2|c", msg), 0);
            AssertWasReceived(String.Format("{0}:3|c", msg), 1);
            AssertWasReceived(null, 2);
        }
开发者ID:Kyle2123,项目名称:statsd-csharp-client,代码行数:18,代码来源:StatsdUDPTests.cs


示例20: single_send_is_thread_safe

        public void single_send_is_thread_safe()
        {
            var counts = new CountingUDP();
            var test = new Statsd(counts);

            // send some commands in parallel, `command' just being a number in sequence
            int sends = 1024, threads = 2; // appears sufficient to surface error most of the time but may vary by machine
            var sent = new ManualResetEvent[threads];
            for (int i = 0; i < threads; i++)
            {
                var done = sent[i] = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(CreateSender(sends, threads, i, test, done));
            }
            // allow threads to complete, cleanup
            WaitHandle.WaitAll(sent);
            foreach (IDisposable d in sent)
                d.Dispose();

            counts.ExpectSequence(sends);
        }
开发者ID:xkrt,项目名称:dogstatsd-csharp-client,代码行数:20,代码来源:StatsdThreadingTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SteamBot.Bot类代码示例发布时间:2022-05-26
下一篇:
C# StateMechanic.StateMachine类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap