protected sealed override void DoInitialize(ILog log, IMetricScope rootMetricScope, AirlockEnvironmentVariables environmentVariables, out IRoutingKeyFilter routingKeyFilter, out IAirlockEventProcessorProvider processorProvider) { routingKeyFilter = new DefaultRoutingKeyFilter(RoutingKey.MetricsSuffix); var graphiteUri = GetGraphiteUri(log, environmentVariables); processorProvider = new DefaultAirlockEventProcessorProvider <MetricEvent, MetricEventSerializer>(project => new MetricsAirlockEventProcessor(graphiteUri, log)); }
public HttpHandler(FrontierSetings setings, IMetricScope metricScope, ILog log, IAirlockClient airlockClient) { this.log = log; this.airlockClient = airlockClient; log.Debug("settings: " + setings?.ToPrettyJson()); var httpScope = metricScope.WithTag(MetricsTagNames.Type, "http"); resendTo = setings?.ResendTo; if (string.IsNullOrWhiteSpace(resendTo)) { resendTo = null; } else { resendHttpClient = new HttpClient(); } reportHandlers = new IReportHandler[] { new StacktraceHandler("stacktracejs", httpScope, log, setings), new ReportHandler <CspReport>("csp", httpScope, log), new ReportHandler <PkpReport>("pkp", httpScope, log) }; var handlerScope = metricScope.WithTag(MetricsTagNames.Operation, "handler"); totalCounter = handlerScope.Counter("total"); errorCounter = handlerScope.Counter("errors"); environment = VostokHostingEnvironment.Current.Environment; }
protected sealed override void DoInitialize(ILog log, IMetricScope rootMetricScope, AirlockEnvironmentVariables environmentVariables, out IRoutingKeyFilter routingKeyFilter, out IAirlockEventProcessorProvider processorProvider) { routingKeyFilter = new DefaultRoutingKeyFilter(RoutingKey.LogsSuffix); var elasticUris = GetElasticUris(log, environmentVariables); processorProvider = new DefaultAirlockEventProcessorProvider <LogEventData, LogEventDataSerializer>(project => new LogAirlockEventProcessor(elasticUris, log)); }
public ProcessorMetrics(IMetricScope metricScope, TimeSpan flushMetricsInterval) { EventProcessedCounter = metricScope.Counter(flushMetricsInterval, "event_processed"); EventIgnoredCounter = metricScope.Counter(flushMetricsInterval, "event_ignored"); EventFailedCounter = metricScope.Counter(flushMetricsInterval, "event_failed"); SendingErrorCounter = metricScope.Counter(flushMetricsInterval, "sending_errors"); }
public static IDisposable Gauge( this IMetricScope scope, string name, Func <double> getValue) { return(scope.Gauge(MetricClock.DefaultPeriod, name, getValue)); }
protected sealed override void DoInitialize(ILog log, IMetricScope rootMetricScope, AirlockEnvironmentVariables environmentVariables, out IRoutingKeyFilter routingKeyFilter, out IAirlockEventProcessorProvider processorProvider) { airlockClient = CreateAirlockClient(log, environmentVariables); routingKeyFilter = new MetricsAggregatorRotingKeyFilter(); var settings = new MetricsAggregatorSettings(); processorProvider = new MetricsAggregatorAirlockEventProcessorProvider(rootMetricScope, airlockClient, settings); }
protected sealed override void DoInitialize(ILog log, IMetricScope rootMetricScope, AirlockEnvironmentVariables environmentVariables, out IRoutingKeyFilter routingKeyFilter, out IAirlockEventProcessorProvider processorProvider) { routingKeyFilter = new DefaultRoutingKeyFilter(RoutingKey.TracesSuffix); var contrailsClientSettings = GetContrailsClientSettings(log, environmentVariables); var contrailsClient = new ContrailsClient(contrailsClientSettings, log); processorProvider = new DefaultAirlockEventProcessorProvider <Span, SpanAirlockSerializer>(project => new TracingAirlockEventProcessor(contrailsClient, log, maxCassandraTasks: 1000)); }
public ReportHandler(string name, IMetricScope metricScope, ILog log) { Name = name; this.log = log; metricScope = metricScope.WithTag(MetricsTagNames.Operation, name); totalCounter = metricScope.Counter("total"); errorCounter = metricScope.Counter("errors"); }
public MetricsAggregatorAirlockEventProcessorProvider( IMetricScope rootMetricScope, IAirlockClient airlockClient, MetricsAggregatorSettings settings) { this.rootMetricScope = rootMetricScope; this.airlockClient = airlockClient; this.settings = settings; }
public static void Uptime( this IMetricScope scope, TimeSpan period) { var startTimestamp = DateTimeOffset.UtcNow; scope.Gauge( period, "uptime", () => (DateTimeOffset.UtcNow - startTimestamp).TotalMilliseconds); }
public MetricsAggregatorProcessor( IAirlockClient airlockClient, IMetricScope rootMetricScope, MetricsAggregatorSettings settings, string eventsRoutingKey) { this.airlockClient = airlockClient; this.rootMetricScope = rootMetricScope; this.settings = settings; this.eventsRoutingKey = eventsRoutingKey; }
public ConsumerMetrics(TimeSpan flushMetricsInterval, IMetricScope rootMetricScope) { statScope = rootMetricScope.WithTag(MetricsTagNames.Type, "libstat"); processorsScope = rootMetricScope.WithTag(MetricsTagNames.Type, "processors"); hostScope = rootMetricScope.WithTag(MetricsTagNames.Type, "grouphost"); var errorsScope = rootMetricScope.WithTag(MetricsTagNames.Type, "error"); CriticalErrorCounter = errorsScope.Counter(flushMetricsInterval, "critical"); ConsumeErrorCounter = errorsScope.Counter(flushMetricsInterval, "consume"); MetricClocks.Get(flushMetricsInterval).Register(WriteMetrics); }
public static void CpuLoad( this IMetricScope scope, TimeSpan period) { var cpuUsage = new CpuUsageMeter(); scope.Gauge(period, "cpu", () => { var processUsage = cpuUsage.Reset().ProcessUsage; return(processUsage); }); }
private static void SendMetricToScope( IMetricScope scope, string name, DateTimeOffset timestamp, double value) { scope .WriteMetric() .SetTimestamp(timestamp) .SetValue(name, value) .Commit(); }
public static void SystemMetrics(this IMetricScope scope, TimeSpan period) { var systemScope = scope.WithTag(MetricsTagNames.Type, "system"); systemScope.CpuLoad(period); systemScope.MemoryUsage(period); systemScope.DiskUsage(period); systemScope.NetworkUsage(period); systemScope.ThreadPool(period); systemScope.GC(period); systemScope.Uptime(period); }
public StacktraceHandler(string name, IMetricScope metricScope, ILog log, FrontierSetings setings) : base(name, metricScope, log) { this.log = log; this.setings = setings; var handler = new HttpClientHandler { AllowAutoRedirect = false }; httpClient = new HttpClient(handler); cache = new NullSafeMemoryCache(); }
public static IDisposable Gauge( this IMetricScope scope, TimeSpan period, string name, Func <double> getValue) { var clock = MetricClocks.Get(period); return(new DisposableMetric( clock, timestamp => { var value = getValue(); SendMetricToScope(scope, name, timestamp, value); })); }
public static ICounter Counter( this IMetricScope scope, TimeSpan period, string name) { var counter = new Counter(); var clock = MetricClocks.Get(period); return(new DisposableCounter( counter, clock, timestamp => { var value = counter.Reset(); SendMetricToScope(scope, name, timestamp, value); })); }
public MetricAggregator( IMetricScope metricScope, IBucketKeyProvider bucketKeyProvider, IAirlockClient airlockClient, TimeSpan cooldownPeriod, Borders borders, string eventsRoutingKey) { aggregatorMetrics = new AggregatorMetrics(metricScope.WithTags(new Dictionary <string, string> { { MetricsTagNames.Type, "aggregation" }, { "routingKey", eventsRoutingKey } })); this.bucketKeyProvider = bucketKeyProvider; this.airlockClient = airlockClient; this.cooldownPeriod = cooldownPeriod; this.borders = borders; metricsRoutingKey = RoutingKey.ReplaceSuffix(eventsRoutingKey, RoutingKey.MetricsSuffix); buckets = new ConcurrentDictionary <BucketKey, IBucket>(); }
public static IMetricScope WithTags(this IMetricScope scope, IReadOnlyDictionary <string, string> tags) { return(new MetricScopeTagEnricher(scope, tags)); }
public static ICounter Counter( this IMetricScope scope, string name) { return(scope.Counter(MetricClock.DefaultPeriod, name)); }
public static void DiskUsage( this IMetricScope scope, TimeSpan period) { }
public static void ThreadPool( this IMetricScope scope, TimeSpan period) { }
public static void GC( this IMetricScope scope, TimeSpan period) { }
public MetricScopeTagEnricher(IMetricScope parent, IReadOnlyDictionary <string, string> tags) { this.parent = parent; this.tags = tags; }
public ProcessorHost(string consumerGroupHostId, string routingKey, IAirlockEventProcessor processor, ILog log, Consumer <Null, byte[]> consumer, IMetricScope metricScope, TimeSpan flushMetricsInterval, ProcessorHostSettings processorHostSettings) { this.routingKey = routingKey; this.processor = processor; this.log = log; this.consumer = consumer; this.processorHostSettings = processorHostSettings; AssignedPartitions = new int[0]; processorThread = new Thread(ProcessorThreadFunc) { IsBackground = true, Name = $"processor-{consumerGroupHostId}-{processor.ProcessorId}", }; queueGauge = metricScope.Gauge(flushMetricsInterval, "queue_size", () => eventsQueue.Count); pausedGauge = metricScope.Gauge(flushMetricsInterval, "paused", () => pausedPartitions != null ? 1 : 0); messageEnqueuedCounter = metricScope.Counter(flushMetricsInterval, "message_enqueued"); processorMetrics = new ProcessorMetrics(metricScope, flushMetricsInterval); }
public EventStopwatch(IMetricScope scope) { writer = scope.WriteEvent(); sw = Stopwatch.StartNew(); }
public AggregatorMetrics(IMetricScope metricScope) { MissedPastEvents = metricScope.Counter(1.Minutes(), "missed_past_events"); MissedFutureEvents = metricScope.Counter(1.Minutes(), "missed_future_events"); }
public static IEventStopwatch EventStopwatch( this IMetricScope scope) { return(new EventStopwatch(scope)); }
public static IMetricScope WithTag(this IMetricScope scope, string key, string value) { return(new MetricScopeTagEnricher(scope, new Dictionary <string, string> { { key, value } })); }