当前位置: 首页>>代码示例>>C#>>正文


C# Statsd.LogCount方法代码示例

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


在下文中一共展示了Statsd.LogCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

示例2: CreateClient_WithInvalidCharactersInHostName_DoesNotError

 public void CreateClient_WithInvalidCharactersInHostName_DoesNotError()
 {
   var statsd = new Statsd("@%)(F(FSDLKDEQ423t0-vbdfb", 12000);
   statsd.LogCount("test.foo");
 }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client-1,代码行数:5,代码来源:StatsdTests.cs

示例3: CreateClient_WithIPAddress_DoesNotError

 public void CreateClient_WithIPAddress_DoesNotError()
 {
   var statsd = new Statsd("127.0.0.1", 12000);
   statsd.LogCount("test.stat");
 }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client-1,代码行数:5,代码来源:StatsdTests.cs

示例4: CreateClient_WithInvalidHostName_DoesNotError

 public void CreateClient_WithInvalidHostName_DoesNotError()
 {
   var statsd = new Statsd("nowhere.here.or.anywhere", 12000);
   statsd.LogCount("test.stat");
 }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client-1,代码行数:5,代码来源:StatsdTests.cs

示例5: LogCount_EmptyStringPrefix_DoesNotStartNameWithPeriod

 public void LogCount_EmptyStringPrefix_DoesNotStartNameWithPeriod()
 {
   var statsd = new Statsd("localhost", 12000, prefix : "", outputChannel : _outputChannel.Object);
   var inputStat = "some.stat:1|c";
   _outputChannel.Setup(p => p.Send(It.Is<string>(q => q == inputStat)))
     .Verifiable();
   statsd.LogCount("some.stat");
   _outputChannel.VerifyAll();
 }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client-1,代码行数:9,代码来源:StatsdTests.cs

示例6: Constructor_PrefixEndsInPeriod_RemovePeriod

    public void Constructor_PrefixEndsInPeriod_RemovePeriod()
    {
      var statsd = new Statsd("localhost", 12000, "foo.", outputChannel : _outputChannel.Object);
      var stat = _testData.NextStatName;
      var count = _testData.NextInteger;
      _outputChannel.Setup(p => p.Send("foo." + stat + ":" + count.ToString() + "|c")).Verifiable();

      statsd.LogCount(stat, count);

      _outputChannel.VerifyAll();
    }
开发者ID:bilal-fazlani,项目名称:statsd-csharp-client-1,代码行数:11,代码来源:StatsdTests.cs


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