private void initializeAndRegisterAllMetrics(TopologyContext context, int timeBucketSize) {
this.failureMetric = new CombinedMetric(new MaxMetric());
this.successCountMetric = new CountMetric();
this.sidelineCountMetric = new CountMetric();
this.internalBufferSize = new CombinedMetric(new MaxMetric());
this.pendingMessageSize = new CombinedMetric(new MaxMetric());
this.currentBinLogFileNumber = new CombinedMetric(new MaxMetric());
this.currentBinLogFilePosition = new CombinedMetric(new MaxMetric());
this.txEventProcessTime = new ReducedMetric(new MeanReducer());
this.txEventFailTimeInTopology = new ReducedMetric(new MeanReducer());
context.registerMetric(SpoutConstants.METRIC_FAILURECOUNT, this.failureMetric, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_SUCCESSCOUNT, this.successCountMetric, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_SIDELINECOUNT, this.sidelineCountMetric, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_BUFFER_SIZE, this.internalBufferSize, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_PENDING_MESSAGES, this.pendingMessageSize, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_TXPROCESSTIME, this.txEventProcessTime, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_BINLOG_FILE_NUM, this.currentBinLogFileNumber, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_BIN_LOG_FILE_POS, this.currentBinLogFilePosition, timeBucketSize);
context.registerMetric(SpoutConstants.METRIC_FAIL_MSG_IN_TOPOLOGY, this.txEventFailTimeInTopology, timeBucketSize);
}