public TaskManagerJobMetricGroup( IMetricRegistry registry, TaskManagerMetricGroup parent, JobId jobId, string jobName) : base(registry, parent, jobId, jobName, null) { }
protected AbstractMetricGroup(IMetricRegistry registry, string[] scope, AbstractMetricGroup <TParent> parent) { Registry = Preconditions.CheckNotNull(registry); ScopeComponents = Preconditions.CheckNotNull(scope); Parent = parent; _scopeStrings = new string[registry.NumberReporters]; }
public DefaultMetricFactory(IClock clock, IMetricRegistry registry) { Guard.ArgNotNull(clock, nameof(clock)); Guard.ArgNotNull(registry, nameof(registry)); _clock = clock; _registry = registry; }
public JobMetricGroup( IMetricRegistry registry, TComponent parent, JobId jobId, string jobName, string[] scope) : base(registry, scope, parent) { }
public TaskManagerMetricGroup( IMetricRegistry registry, string hostname, string taskManagerId) : base(registry, null, null) { Hostname = hostname; TaskManagerId = taskManagerId; }
private dynamic GetSeries(IMetricRegistry metricRegistry, IMetricAggregator metricAggregator, ExpressionCompiler expressionCompiler) { try { var model = new SeriesQueryModel(); this.BindTo(model, new BindingConfig { BodyOnly = false }); var now = DateTime.UtcNow; var from = DateTimeParser.ParseDateTime(model.From, now, now.AddHours(-1)); var until = DateTimeParser.ParseDateTime(model.Until, now, now); var environment = new Statsify.Core.Expressions.Environment { MetricRegistry = metricRegistry, QueuedMetricDatapoints = metricAggregator.Queue }; var evalContext = new EvalContext(@from, until); var metrics = new List <Core.Model.Metric>(); foreach (var expression in model.Expression.Select(HttpUtility.UrlDecode)) { var e = expressionCompiler.Parse(expression).Single(); if (e is MetricSelectorExpression) { e = new EvaluatingMetricSelectorExpression(e as MetricSelectorExpression); } // if var r = (Core.Model.Metric[])e.Evaluate(environment, evalContext); metrics.AddRange(r); } // foreach var seriesViewList = metrics. Select(m => new SeriesView { Target = m.Name, Datapoints = m.Series.Datapoints. Select(d => new[] { d.Value, d.Timestamp.ToUnixTimestamp() }). ToArray() }). ToArray(); return(Response.AsJson(seriesViewList)); } catch (Exception e) { return(Response.AsJson(new { e.Message, e.StackTrace }, HttpStatusCode.InternalServerError)); } }
public static T Metric <TArg>(IMetricRegistry registry, string name, Func <string, TArg, IMetricFamily> factory, TArg arg) { var metric = registry.GetOrAdd(name, factory, arg); if (metric is T m) { return(m); } throw new InvalidOperationException($"Metric {name} is already created with a different type {metric.GetType().Name}"); }
public GraphiteApiModule(IMetricService metricService, IMetricRegistry metricRegistry, IMetricAggregator metricAggregator, ExpressionCompiler expressionCompiler) : base("/api/graphite/v1") { this.metricService = metricService; this.metricRegistry = metricRegistry; this.metricAggregator = metricAggregator; this.expressionCompiler = expressionCompiler; Get["/metrics/find"] = Get["/metrics"] = Post["/metrics/find"] = Post["/metrics"] = QueryMetrics; Get["/render"] = Post["/render"] = RenderSeries; }
public MetricServerMiddleware( RequestDelegate next, IOptions <MetricServerOptions> options, IMetricRegistry registry) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } _options = options.Value; _registry = registry; }
public JobManagerMetricGroup(IMetricRegistry registry, string hostname) : base(registry, null, null) { Hostname = hostname; }
public ApiModule(IMetricService metricService, IAnnotationRegistry annotationRegistry, IMetricRegistry metricRegistry, IMetricAggregator metricAggregator, ExpressionCompiler expressionCompiler) : base("/api/v1") { JsonSettings.MaxJsonLength = int.MaxValue; Get["find/{query}"] = x => { string query = x.query; var metrics = metricService.Find(query); return(Response.AsJson(metrics)); }; Get["annotations"] = x => { var model = new AnnotationsQueryModel(); this.BindTo(model, new BindingConfig { BodyOnly = false }); var now = DateTime.UtcNow; var from = DateTimeParser.ParseDateTime(model.From, now, now.AddHours(-1)); var until = DateTimeParser.ParseDateTime(model.Until, now, now); var annotations = annotationRegistry. ReadAnnotations(from, until). Where(a => model.Tag == null || model.Tag.Length == 0 || a.Tags.Intersect(model.Tag).Any()). Select(a => new { Timestamp = a.Timestamp.ToUnixTimestamp(), a.Title, a.Message });; return(Response.AsJson(annotations)); }; Post["annotations"] = x => { string title = Request.Form.title; string message = Request.Form.message; annotationRegistry.WriteAnnotation(new Annotation(DateTime.UtcNow, title, message)); return(Response.AsJson(new { Success = true })); }; Get["series"] = x => GetSeries(metricRegistry, metricAggregator, expressionCompiler); Post["purge"] = x => { var model = new PurgeModel(); this.BindTo(model, new BindingConfig { BodyOnly = false }); var now = DateTime.UtcNow; var from = DateTimeParser.ParseDateTime(model.From, now, now.AddYears(-1)); metricRegistry.PurgeMetrics(from); return(204); }; Post["metrics"] = x => PostMetrics(metricAggregator); }
/// <summary> /// Creates a new ComponentMetricGroup. /// </summary> /// <param name="registry">registry to register new metrics with</param> /// <param name="scope">the scope of the group</param> /// <param name="parent"></param> protected ComponentMetricGroup(IMetricRegistry registry, string[] scope, AbstractMetricGroup <TParent> parent) : base(registry, scope, parent) { }