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