Exemplo n.º 1
0
 public static string ToJsonString(HystrixCollapserMetrics collapserMetrics)
 {
     using var sw     = new StringWriter();
     using var writer = new JsonTextWriter(sw);
     WriteCollapserMetrics(writer, collapserMetrics);
     return(sw.ToString());
 }
Exemplo n.º 2
0
        public void Before()
        {
            context = HystrixRequestContext.InitializeContext();

            HystrixCommandMetrics.Reset();
            HystrixThreadPoolMetrics.Reset();
            HystrixCollapserMetrics.Reset();

            // clear collapsers
            RequestCollapserFactory.Reset();

            // clear circuit breakers
            HystrixCircuitBreakerFactory.Reset();
            HystrixPlugins.Reset();
            HystrixOptionsFactory.Reset();

            // clear up all streams
            CumulativeCollapserEventCounterStream.Reset();
            CumulativeCommandEventCounterStream.Reset();
            CumulativeThreadPoolEventCounterStream.Reset();
            RollingCollapserBatchSizeDistributionStream.Reset();
            RollingCollapserEventCounterStream.Reset();
            RollingCommandEventCounterStream.Reset();
            RollingCommandLatencyDistributionStream.Reset();
            RollingCommandMaxConcurrencyStream.Reset();
            RollingCommandUserLatencyDistributionStream.Reset();
            RollingThreadPoolEventCounterStream.Reset();
            RollingThreadPoolMaxConcurrencyStream.Reset();
        }
        public HystrixDashboardStream.DashboardData GetTestData()
        {
            var commandKey   = new HystrixCommandKeyDefault("command");
            var tpKey        = new HystrixThreadPoolKeyDefault("threadPool");
            var collapserKey = new HystrixCollapserKeyDefault("collapser");

            var commandMetric = new HystrixCommandMetrics(
                commandKey,
                new HystrixCommandGroupKeyDefault("group"),
                tpKey,
                new HystrixCommandOptions(),
                HystrixEventNotifierDefault.GetInstance());
            var threadPoolMetric = HystrixThreadPoolMetrics.GetInstance(
                tpKey,
                new HystrixSyncTaskScheduler(new HystrixThreadPoolOptions()),
                new HystrixThreadPoolOptions());
            var commandMetrics = new List <HystrixCommandMetrics>()
            {
                commandMetric
            };
            var collapserOptions  = new HystrixCollapserOptions(collapserKey);
            var threadPoolMetrics = new List <HystrixThreadPoolMetrics>()
            {
                threadPoolMetric
            };

            var collapserMetrics = new List <HystrixCollapserMetrics>()
            {
                HystrixCollapserMetrics.GetInstance(collapserKey, collapserOptions)
            };

            return(new HystrixDashboardStream.DashboardData(commandMetrics, threadPoolMetrics, collapserMetrics));
        }
 public HystrixTestBase()
 {
     HystrixCommandMetrics.Reset();
     HystrixThreadPoolMetrics.Reset();
     HystrixCollapserMetrics.Reset();
     // clear collapsers
     RequestCollapserFactory.Reset();
     // clear circuit breakers
     HystrixCircuitBreakerFactory.Reset();
     HystrixPlugins.Reset();
     HystrixOptionsFactory.Reset();
 }
Exemplo n.º 5
0
        public HystrixTestBase()
        {
            this.context = HystrixRequestContext.InitializeContext();

            HystrixCommandMetrics.Reset();
            HystrixThreadPoolMetrics.Reset();
            HystrixCollapserMetrics.Reset();
            // clear collapsers
            RequestCollapserFactory.Reset();
            // clear circuit breakers
            HystrixCircuitBreakerFactory.Reset();
            HystrixPlugins.Reset();
            HystrixOptionsFactory.Reset();
        }
Exemplo n.º 6
0
        private static void WriteCollapserMetrics(JsonTextWriter writer, HystrixCollapserMetrics collapserMetrics)
        {
            IHystrixCollapserKey key = collapserMetrics.CollapserKey;

            writer.WriteStartObject();

            writer.WriteStringField("type", "HystrixCollapser");
            writer.WriteStringField("name", key.Name);
            writer.WriteLongField("currentTime", Time.CurrentTimeMillisJava);

            writer.WriteLongField("rollingCountRequestsBatched", collapserMetrics.GetRollingCount(CollapserEventType.ADDED_TO_BATCH));

            writer.WriteLongField("rollingCountBatches", collapserMetrics.GetRollingCount(CollapserEventType.BATCH_EXECUTED));

            writer.WriteLongField("rollingCountResponsesFromCache", collapserMetrics.GetRollingCount(CollapserEventType.RESPONSE_FROM_CACHE));


            // batch size percentiles
            writer.WriteIntegerField("batchSize_mean", collapserMetrics.BatchSizeMean);
            writer.WriteObjectFieldStart("batchSize");
            writer.WriteIntegerField("25", collapserMetrics.GetBatchSizePercentile(25));
            writer.WriteIntegerField("50", collapserMetrics.GetBatchSizePercentile(50));
            writer.WriteIntegerField("75", collapserMetrics.GetBatchSizePercentile(75));
            writer.WriteIntegerField("90", collapserMetrics.GetBatchSizePercentile(90));
            writer.WriteIntegerField("95", collapserMetrics.GetBatchSizePercentile(95));
            writer.WriteIntegerField("99", collapserMetrics.GetBatchSizePercentile(99));
            writer.WriteIntegerField("99.5", collapserMetrics.GetBatchSizePercentile(99.5));
            writer.WriteIntegerField("100", collapserMetrics.GetBatchSizePercentile(100));
            writer.WriteEndObject();


            writer.WriteBooleanField("propertyValue_requestCacheEnabled", collapserMetrics.Properties.RequestCacheEnabled);
            writer.WriteIntegerField("propertyValue_maxRequestsInBatch", collapserMetrics.Properties.MaxRequestsInBatch);
            writer.WriteIntegerField("propertyValue_timerDelayInMilliseconds", collapserMetrics.Properties.TimerDelayInMilliseconds);

            writer.WriteIntegerField("reportingHosts", 1); // this will get summed across all instances in a cluster

            writer.WriteEndObject();
        }
Exemplo n.º 7
0
 public virtual IHystrixMetricsPublisherCollapser GetMetricsPublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties)
 {
     return(new HystrixMetricsPublisherCollapserDefault(collapserKey, metrics, properties));
 }
Exemplo n.º 8
0
 public HystrixMetricsPublisherCollapserDefault(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties)
 {
     // do nothing by default
 }
Exemplo n.º 9
0
 private HystrixDashboardStream(int delayInMs)
 {
     this.delayInMs    = delayInMs;
     this.singleSource = Observable.Interval(TimeSpan.FromMilliseconds(delayInMs))
                         .Map((timestamp) => { return(new DashboardData(HystrixCommandMetrics.GetInstances(), HystrixThreadPoolMetrics.GetInstances(), HystrixCollapserMetrics.GetInstances())); })
                         .OnSubscribe(() => { isSourceCurrentlySubscribed.Value = true; })
                         .OnDispose(() => { isSourceCurrentlySubscribed.Value = false; })
                         .Publish().RefCount();
 }
Exemplo n.º 10
0
 internal IHystrixMetricsPublisherCollapser GetPublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties)
 {
     return(collapserPublishers.GetOrAddEx(collapserKey.Name, (k) =>
     {
         IHystrixMetricsPublisherCollapser publisher = HystrixPlugins.MetricsPublisher.GetMetricsPublisherForCollapser(collapserKey, metrics, properties);
         publisher.Initialize();
         return publisher;
     }));
 }
Exemplo n.º 11
0
 public static IHystrixMetricsPublisherCollapser CreateOrRetrievePublisherForCollapser(IHystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, IHystrixCollapserOptions properties)
 {
     return(SINGLETON.GetPublisherForCollapser(collapserKey, metrics, properties));
 }