public WindowedStreamConsumer([NotNull] WindowedStreamConsumerSettings <T, TKey> settings, [CanBeNull] ILog log) : base(settings, log) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.log = (log ?? LogProvider.Get()).ForContext <WindowedStreamConsumer <T, TKey> >(); tracer = settings.Tracer ?? TracerProvider.Get(); windows = new Dictionary <TKey, Windows <T, TKey> >(); var applicationMetricContext = settings.ApplicationMetricContext ?? new DevNullMetricContext(); eventLagMetric = applicationMetricContext.CreateHistogram("eventLag", new HistogramConfig { Buckets = HistogramHelper.CreateDefaultBuckets(), Unit = WellKnownUnits.Milliseconds }); var instanceMetricContext = settings.InstanceMetricContext ?? new DevNullMetricContext(); stateMetric = instanceMetricContext.CreateIntegerGauge("state", "type"); var settingsOnBatchEnd = settings.OnBatchEnd; settings.OnBatchEnd = c => { FlushWindows(); Task.Run(() => settings.LeftCoordinatesStorage.AdvanceAsync(leftCoordinates)); settingsOnBatchEnd?.Invoke(c); }; var settingsOnEvent = settings.OnEvent; settings.OnEvent = (e, c) => { AddEvent(e, c); settingsOnEvent?.Invoke(e, c); }; var settingsOnRestart = settings.OnRestart; settings.OnRestart = c => { Restart(c).GetAwaiter().GetResult(); settingsOnRestart?.Invoke(c); }; var settingsOnStop = settings.OnStop; settings.OnStop = c => { Stop(c).GetAwaiter().GetResult(); settingsOnStop?.Invoke(c); }; }
public StreamBinaryWriter([NotNull] StreamBinaryWriterSettings settings, [CanBeNull] ILog log) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.log = log = (log ?? LogProvider.Get()).ForContext <StreamBinaryWriter>(); var bufferPool = new BufferPool(settings.MaxPooledBufferSize, settings.MaxPooledBuffersPerBucket); client = new GateRequestSender(settings.GateCluster, log /*.WithErrorsTransformedToWarns()*/, bufferPool, settings.GateClientAdditionalSetup); tracer = settings.Tracer ?? TracerProvider.Get(); eventsMetric = settings.MetricContext?.CreateIntegerGauge("events", "type", new IntegerGaugeConfig { ResetOnScrape = true }); iterationMetric = settings.MetricContext?.CreateSummary("iteration", "type", new SummaryConfig { Quantiles = new[] { 0.5, 0.75, 1 } }); settings.MetricContext?.CreateFuncGauge("buffer", "type").For("rented_writer").SetValueProvider(() => BufferPool.Rented); }
public BatchesStreamConsumer([NotNull] BatchesStreamConsumerSettings <T> settings, [CanBeNull] ILog log) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.log = log = (log ?? LogProvider.Get()).ForContext <BatchesStreamConsumer <T> >(); tracer = settings.Tracer ?? TracerProvider.Get(); var bufferPool = new BufferPool(settings.MaxPooledBufferSize, settings.MaxPooledBuffersPerBucket); client = new StreamApiRequestSender(settings.StreamApiCluster, log /*.WithErrorsTransformedToWarns()*/, bufferPool, settings.StreamApiClientAdditionalSetup); var instanceMetricContext = settings.InstanceMetricContext ?? new DevNullMetricContext(); eventsMetric = instanceMetricContext.CreateIntegerGauge("events", "type", new IntegerGaugeConfig { ResetOnScrape = true }); iterationMetric = instanceMetricContext.CreateSummary("iteration", "type", new SummaryConfig { Quantiles = new[] { 0.5, 0.75, 1 } }); instanceMetricContext.CreateFuncGauge("events", "type").For("remaining").SetValueProvider(CountStreamRemainingEvents); instanceMetricContext.CreateFuncGauge("buffer", "type").For("rented_reader").SetValueProvider(() => BufferPool.Rented); }
public WindowedStreamConsumer([NotNull] WindowedStreamConsumerSettings <T, TKey> settings, [CanBeNull] ILog log) : base(settings, log) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.log = (log ?? LogProvider.Get()).ForContext <WindowedStreamConsumer <T, TKey> >(); tracer = settings.Tracer ?? TracerProvider.Get(); windows = new Dictionary <TKey, Windows <T, TKey> >(); var settingsOnBatchEnd = settings.OnBatchEnd; settings.OnBatchEnd = c => { FlushWindows(); settings.LeftCoordinatesStorage.AdvanceAsync(leftCoordinates); settingsOnBatchEnd?.Invoke(c); }; var settingsOnEvent = settings.OnEvent; settings.OnEvent = (e, c) => { AddEvent(e, c); settingsOnEvent?.Invoke(e, c); }; var settingsOnRestart = settings.OnRestart; settings.OnRestart = c => { Restart(c).GetAwaiter().GetResult(); settingsOnRestart?.Invoke(c); }; var metricContext = settings.MetricContext ?? new DevNullMetricContext(); stateMetric = metricContext.CreateIntegerGauge("state", "type"); }
public ScheduledActionsBuilder(ILog log) : this(log, TracerProvider.Get()) { }