本文整理汇总了C#中Metric类的典型用法代码示例。如果您正苦于以下问题:C# Metric类的具体用法?C# Metric怎么用?C# Metric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Metric类属于命名空间,在下文中一共展示了Metric类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
private static void Log(StringBuilder builder, Metric metric, List<object> metricValues)
{
if (metricValues == null || metricValues.Count == 0)
LogHelper(builder, metric);
else
LogHelper(builder, metric, metricValues.ToArray());
}
示例2: RestClient_posts_metrics
public async void RestClient_posts_metrics()
{
var metricName = GetUniqueMetricName();
var dataPoint = new DataPoint(DateTime.UtcNow.MillisecondsSinceEpoch(), 5L);
var metric = new Metric(metricName)
.AddTag("route_id", "1")
.AddDataPoint(dataPoint);
await _client.AddMetricsAsync(new[] {metric});
var query = new QueryBuilder()
.SetStart(TimeSpan.FromSeconds(5))
.AddQueryMetric(new QueryMetric(metricName));
Thread.Sleep(TimeSpan.FromSeconds(2));
var response = await _client.QueryMetricsAsync(query);
response.Queries.Should().HaveCount(1);
response.Queries[0].SampleSize.Should().Be(1);
response.Queries[0].Results.Should().HaveCount(1);
response.Queries[0].Results[0].DataPoints.Single().ShouldBeEquivalentTo(dataPoint);
}
示例3: PerformanceCounterMonitor
/// <summary>
/// Create a new <see cref="PerformanceCounterMonitor"/> actor.
/// </summary>
/// <param name="seriesName">
/// The name of the data series that tracks the performance counter's value.
/// </param>
/// <param name="performanceCounterFactory">
/// A factory delegate that creates the <see cref="PerformanceCounter"/> to monitor.
/// </param>
public PerformanceCounterMonitor(string seriesName, Func<PerformanceCounter> performanceCounterFactory)
{
if (String.IsNullOrWhiteSpace(seriesName))
throw new ArgumentException("Argument cannot be null, empty, or entirely componsed of whitespace: 'seriesName'.", nameof(seriesName));
if (performanceCounterFactory == null)
throw new ArgumentNullException(nameof(performanceCounterFactory));
_seriesName = seriesName;
_performanceCounterFactory = performanceCounterFactory;
_cancelPublishing = new Cancelable(Context.System.Scheduler);
Receive<GatherMetrics>(_ =>
{
Metric metric = new Metric(
_seriesName,
_performanceCounter.NextValue()
);
foreach (IActorRef subscriber in _subscribers)
subscriber.Tell(metric);
});
Receive<SubscribePerformanceCounter>(request =>
{
_subscribers.Add(request.Subscriber);
});
Receive<UnsubscribePerformanceCounter>(request =>
{
_subscribers.Remove(request.Subscriber);
});
}
示例4: QueryMetricsAsync_uses_sum_aggregator
public async void QueryMetricsAsync_uses_sum_aggregator()
{
var metricName = GetUniqueMetricName();
var time = DateTime.UtcNow.MillisecondsSinceEpoch();
var dataPoint = new DataPoint(time, 10L);
var dataPoint2 = new DataPoint(time + 1, 30L);
var metric = new Metric(metricName)
.AddTag("route_id", "1")
.AddDataPoint(dataPoint2)
.AddDataPoint(dataPoint);
await _client.AddMetricsAsync(new[] { metric });
var queryMetric = new QueryMetric(metricName)
.AddAggregator(new SumAggregator(1, TimeUnit.Minutes));
var query = new QueryBuilder()
.SetStart(TimeSpan.FromSeconds(10))
.AddQueryMetric(queryMetric);
Thread.Sleep(TimeSpan.FromSeconds(2));
var response = await _client.QueryMetricsAsync(query);
response.Queries.Should().HaveCount(1);
response.Queries[0].Results.Should().HaveCount(1);
response.Queries[0].Results[0].DataPoints.Single().Value.Should().Be(40L);
}
示例5: Publish
public async Task Publish(Metric[] metrics)
{
foreach (var metric in metrics)
{
Publish(metric);
}
}
示例6: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
AddPullToRefresh ();
// add the nav button.
UIBarButtonItem addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
addButton.Clicked += async (sender, e) => {
var addController = new AddCheckinViewController();
this.NavigationController.PushViewController(addController,true);
_dataSource.Clear();
var result = await Buddy.RecordMetricAsync("adding_checkin", null, TimeSpan.FromDays(1));
if (result.IsSuccess) {
_timedMetric = result.Value;
}
};
this.NavigationItem.RightBarButtonItem = addButton;
UIBarButtonItem logoutButton = new UIBarButtonItem ("Logout", UIBarButtonItemStyle.Plain,
async (s, e) => {
await Buddy.LogoutUserAsync();
});
this.NavigationItem.LeftBarButtonItem = logoutButton;
_dataSource = new CheckinDataSource (this);
this.checkinTable.Source = _dataSource;
}
示例7: IsMetricMatch
public bool IsMetricMatch(Metric metric)
{
if (metric == null)
return false;
return this.typeCheck.IsMatch(metric.Type)
&& this.backend.SupportedTypes.Contains(metric.Type, StringComparer.OrdinalIgnoreCase);
}
示例8: TracerFactory
public TracerFactory(string metricName, string name, string transactionNamingPriority, Metric metric)
: this()
{
this.Name = name;
this.TransactionNamingPriority = transactionNamingPriority;
this.MetricName = metricName;
this.Metric = metric;
}
示例9: IsRouted
public static Action<StatrContext> IsRouted(Metric metric)
{
return context =>
{
var router = context.Container.Resolve<IMetricRouter>();
router.Route(metric);
};
}
示例10: NotifyMetric
public void NotifyMetric(Metric metric)
{
var handler = MetricReceived;
if (handler != null)
{
handler(this, new MetricEventArgs(metric));
}
}
示例11: InstrumentationTarget
public InstrumentationTarget(IMethodDetails target, string metricName, string name, string transactionNamingPriority, Metric metric)
{
this.Target = target;
this.MetricName = metricName;
this.Name = name;
this.TransactionNamingPriority = transactionNamingPriority;
this.Metric = metric;
}
示例12: TryAppend
public bool TryAppend(Metric metric, Encoding encoding)
{
try {
position += metric.GetBytes(encoding, bytes, position);
return true;
} catch(ArgumentException) {
return false;
}
}
示例13: InstrumentAttribute
public InstrumentAttribute(string metricName, string name, string transactionNamingPriority, Metric metric)
{
this.Scopes = InstrumentationScopes.All;
this.Name = name;
this.TransactionNamingPriority = transactionNamingPriority;
this.MetricName = metricName;
this.Metric = metric;
}
示例14: parsing
public void parsing(string input, string name, string value, MetricType type) {
var result = new Metric();
Check.That(
() => Metric.TryParse(input, out result),
() => result.Name == name,
() => result.Value.ToString() == value,
() => result.Value.Type == type
);
}
示例15: Timer
public Timer(
Metric.Client.ITimingCompletionRecorder timingCompletionRecorder,
string key)
{
this.c_timingCompletionRecorder = timingCompletionRecorder;
this.c_key = key;
this.c_stopWatch = Stopwatch.StartNew();
}