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


C# StatsdClient.Statsd類代碼示例

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


Statsd類屬於StatsdClient命名空間,在下文中一共展示了Statsd類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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