{"record":{"id":"519b21b8240c2ca5","repo":"Netflix/Hystrix","slug":"you-have-set-the-bucket-size-to-0ms-please-set-a","errorCode":null,"errorMessage":"You have set the bucket size to 0ms.  Please set a positive number, so that the metric stream can be properly consumed","messagePattern":"You have set the bucket size to 0ms\\.  Please set a positive number, so that the metric stream can be properly consumed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/metric/consumer/HealthCountsStream.java","lineNumber":58,"sourceCode":" */\npublic class HealthCountsStream extends BucketedRollingCounterStream<HystrixCommandCompletion, long[], HystrixCommandMetrics.HealthCounts> {\n\n    private static final ConcurrentMap<String, HealthCountsStream> streams = new ConcurrentHashMap<String, HealthCountsStream>();\n\n    private static final int NUM_EVENT_TYPES = HystrixEventType.values().length;\n\n    private static final Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts> healthCheckAccumulator = new Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts>() {\n        @Override\n        public HystrixCommandMetrics.HealthCounts call(HystrixCommandMetrics.HealthCounts healthCounts, long[] bucketEventCounts) {\n            return healthCounts.plus(bucketEventCounts);\n        }\n    };\n\n\n    public static HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties) {\n        final int healthCountBucketSizeInMs = properties.metricsHealthSnapshotIntervalInMilliseconds().get();\n        if (healthCountBucketSizeInMs == 0) {\n            throw new RuntimeException(\"You have set the bucket size to 0ms.  Please set a positive number, so that the metric stream can be properly consumed\");\n        }\n        final int numHealthCountBuckets = properties.metricsRollingStatisticalWindowInMilliseconds().get() / healthCountBucketSizeInMs;\n\n        return getInstance(commandKey, numHealthCountBuckets, healthCountBucketSizeInMs);\n    }\n\n    public static HealthCountsStream getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs) {\n        HealthCountsStream initialStream = streams.get(commandKey.name());\n        if (initialStream != null) {\n            return initialStream;\n        } else {\n            final HealthCountsStream healthStream;\n            synchronized (HealthCountsStream.class) {\n                HealthCountsStream existingStream = streams.get(commandKey.name());\n                if (existingStream == null) {\n                    HealthCountsStream newStream = new HealthCountsStream(commandKey, numBuckets, bucketSizeInMs,\n                            HystrixCommandMetrics.appendEventToBucket);\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/metric/consumer/HealthCountsStream.java#L40-L76","documentation":"HealthCountsStream.getInstance(commandKey, properties) derives the health-count bucket size from metricsHealthSnapshotIntervalInMilliseconds (default 500ms); if that property was explicitly set to 0, health-count buckets cannot be created and a RuntimeException tells you to set a positive number so the metric stream (feeding the circuit breaker's snapshot) can be consumed.","triggerScenarios":"Setting hystrix.command.<key>.metrics.healthSnapshot.intervalInMilliseconds=0 (or programmatically withHealthSnapshotIntervalInMilliseconds(0)) for a command whose health stream then gets initialized; often a misguided attempt to disable health metrics.","commonSituations":"Teams zeroing the health snapshot interval believing it disables metrics overhead; global default override via Archaius (hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=0) breaking every command; config copy-paste from tuning guides.","solutions":["Set the interval to a positive value (default 500ms): hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=500","To reduce overhead, raise the interval rather than zeroing it (e.g. 1000–5000ms)","If health metrics are truly unwanted, the interval property is not the off switch — leave it positive and ignore the stream"],"exampleFix":"# before\nhystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=0\n# after\nhystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=500","handlingStrategy":"validation","validationCode":"int interval = properties.metricsHealthSnapshotIntervalInMilliseconds().get();\nif (interval <= 0) throw new IllegalArgumentException(\"healthSnapshot.intervalInMilliseconds must be > 0 (default 500)\");","typeGuard":"null","tryCatchPattern":"Fail fast at config load — catching this at stream initialization is too late.","preventionTips":["Never set metrics.healthSnapshot.intervalInMilliseconds to 0","Validate Hystrix properties at application startup","Raise the interval (not zero it) to cut metrics overhead"],"tags":["java","hystrix","configuration","metrics","circuit-breaker"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}