本文整理汇总了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();
}
示例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);
});
}
示例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();
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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);
}
示例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"));
}
示例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));
}
示例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));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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);
}
示例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"));
}