public EpoxyTransport( ILayerStackProvider layerStackProvider, Func <string, Task <IPAddress> > resolver, EpoxyServerTlsConfig serverTlsConfig, EpoxyClientTlsConfig clientTlsConfig, TimeoutConfig timeoutConfig, ILogSink logSink, bool enableDebugLogs, IMetricsSink metricsSink) { // Layer stack provider may be null this.layerStackProvider = layerStackProvider; // Always need a resolver, so substitute in default if given null this.resolver = resolver ?? ResolveViaDnsAsync; // may be null - indicates no TLS for listeners this.serverTlsConfig = serverTlsConfig; // Client-side TLS is determined by how the connection is // established, so we substitute in the Default TLS config if we // happened to get null this.clientTlsConfig = clientTlsConfig ?? EpoxyClientTlsConfig.Default; this.timeoutConfig = timeoutConfig; // Log sink may be null logger = new Logger(logSink, enableDebugLogs); // Metrics sink may be null metrics = new Metrics(metricsSink); connections = new CleanupCollection <EpoxyConnection>(); listeners = new CleanupCollection <EpoxyListener>(); }
public MetricsCollector(IMetricsSink sink, MetricsCollectorSettings settings) : this(sink, TimeSpan.ParseExact(settings.WindowSize, "h\\:mm\\:ss", CultureInfo.InvariantCulture), TimeSpan.ParseExact(settings.FlushInterval, "h\\:mm\\:ss", CultureInfo.InvariantCulture), settings.IgnoreEmptyBuckets) { }
/// <summary> /// Initializes a new instance of the <see cref="T:Wibblr.Metrics.Core.EventCollector"/> class. /// This particular constructor is internal as it contains a parameter for the IClock, /// which is only used during testing. /// </summary> /// <param name="sink">Sink.</param> /// <param name="clock">Clock.</param> /// <param name="windowSize">Resolution.</param> /// <param name="flushInterval">Flush interval.</param> internal MetricsCollector(IMetricsSink sink, IClock clock, TimeSpan windowSize, TimeSpan flushInterval, bool ignoreEmptyBuckets) { if (windowSize.TotalMilliseconds < 100) { throw new ArgumentException("Must be 100ms or greater", nameof(windowSize)); } if (flushInterval.TotalMilliseconds < 200) { throw new ArgumentException("Must be 200ms or greater", nameof(flushInterval)); } if (flushInterval < windowSize) { throw new ArgumentException("Cannot be less than the window size", nameof(flushInterval)); } if (!windowSize.IsDivisorOf(TimeSpan.FromDays(1))) { throw new ArgumentException("Must be whole number of windows per day", nameof(windowSize)); } this.sink = sink; this.clock = clock; this.windowSize = windowSize; this.flushInterval = flushInterval; this.ignoreEmptyBuckets = true; clock.SetDelayedAction(Flush); clock.ExecuteAfterDelay(flushInterval); }
public EpoxyTransport( ILayerStackProvider layerStackProvider, ILogSink logSink, bool enableDebugLogs, IMetricsSink metricsSink) { // Layer stack provider may be null this.layerStackProvider = layerStackProvider; // Log sink may be null logger = new Logger(logSink, enableDebugLogs); // Metrics sink may be null metrics = new Metrics(metricsSink); }
public void Setup() { names = Enumerable.Range(0, 50) .Select(x => Guid.NewGuid().ToString()) .ToArray(); sink = new TextWriterSink(Console.Out, new LineSerializer()); metrics = new MetricsCollector(sink, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); foreach (var name in names) { metrics.RegisterThresholds(name, new[] { 0, 10, 20, 30, 50, 75, 100 }); } }
private static async Task <EpoxyTransport> Server( ILogSink logSink, IMetricsSink metricsSink, IPEndPoint endPoint) { var transport = new EpoxyTransportBuilder() .SetLogSink(logSink) .SetMetricsSink(metricsSink) .Construct(); var service = new DummyTestService(); var listener = transport.MakeListener(endPoint); listener.AddService(service); await listener.StartAsync(); return(transport); }
private async Task<EpoxyTransport> Server( ILogSink logSink, IMetricsSink metricsSink, IPEndPoint endPoint) { var transport = new EpoxyTransportBuilder() .SetLogSink(logSink) .SetMetricsSink(metricsSink) .Construct(); var service = new DummyTestService(); var listener = transport.MakeListener(endPoint); listeners.Add(listener); listener.AddService(service); await listener.StartAsync(); return transport; }
public Metrics(IMetricsSink metricsSink) { Sink = metricsSink; }
/// <summary> /// Initializes a new instance of the <see cref="T:Wibblr.Metrics.Core.CounterCollector"/> class. /// </summary> /// <param name="sink">The sink to write the events to.</param> /// <param name="windowSize">Resolution.</param> /// <param name="flushInterval">Batch will be flushed when this amount of time has passed</param> public MetricsCollector(IMetricsSink sink, TimeSpan windowSize, TimeSpan flushInterval, bool ignoreEmptyBuckets = false) : this(sink, new Clock(), windowSize, flushInterval, ignoreEmptyBuckets) { }
/// <summary> /// Initializes a new instance of the <see cref="T:Wibblr.Metrics.Core.CounterCollector"/> class. /// with default values (window size and flush interval are 1 minute) /// </summary> /// <param name="sink">The sink to write the events to.</param> public MetricsCollector(IMetricsSink sink) : this(sink, new Clock(), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60), false) { }
public Metrics(IMetricsSink metricsSink) { Sink = metricsSink; }
public virtual TransportBuilder <TTransport> SetMetricsSink(IMetricsSink metricsSink) { MetricsSink = metricsSink; return(this); }