mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: BigchainDB benchmark logs are not needed
This commit is contained in:
parent
407571ddf4
commit
9469c47f86
@ -146,16 +146,13 @@ class App(BaseApplication):
|
|||||||
|
|
||||||
self.abort_if_abci_chain_is_not_synced()
|
self.abort_if_abci_chain_is_not_synced()
|
||||||
|
|
||||||
logger.benchmark('CHECK_TX_INIT')
|
|
||||||
logger.debug('check_tx: %s', raw_transaction)
|
logger.debug('check_tx: %s', raw_transaction)
|
||||||
transaction = decode_transaction(raw_transaction)
|
transaction = decode_transaction(raw_transaction)
|
||||||
if self.bigchaindb.is_valid_transaction(transaction):
|
if self.bigchaindb.is_valid_transaction(transaction):
|
||||||
logger.debug('check_tx: VALID')
|
logger.debug('check_tx: VALID')
|
||||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
|
||||||
return ResponseCheckTx(code=CodeTypeOk)
|
return ResponseCheckTx(code=CodeTypeOk)
|
||||||
else:
|
else:
|
||||||
logger.debug('check_tx: INVALID')
|
logger.debug('check_tx: INVALID')
|
||||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
|
||||||
return ResponseCheckTx(code=CodeTypeError)
|
return ResponseCheckTx(code=CodeTypeError)
|
||||||
|
|
||||||
def begin_block(self, req_begin_block):
|
def begin_block(self, req_begin_block):
|
||||||
@ -167,7 +164,7 @@ class App(BaseApplication):
|
|||||||
self.abort_if_abci_chain_is_not_synced()
|
self.abort_if_abci_chain_is_not_synced()
|
||||||
|
|
||||||
chain_shift = 0 if self.chain is None else self.chain['height']
|
chain_shift = 0 if self.chain is None else self.chain['height']
|
||||||
logger.benchmark('BEGIN BLOCK, height:%s, num_txs:%s',
|
logger.debug('BEGIN BLOCK, height:%s, num_txs:%s',
|
||||||
req_begin_block.header.height + chain_shift,
|
req_begin_block.header.height + chain_shift,
|
||||||
req_begin_block.header.num_txs)
|
req_begin_block.header.num_txs)
|
||||||
|
|
||||||
@ -253,7 +250,6 @@ class App(BaseApplication):
|
|||||||
logger.debug('Commit-ing new block with hash: apphash=%s ,'
|
logger.debug('Commit-ing new block with hash: apphash=%s ,'
|
||||||
'height=%s, txn ids=%s', data, self.new_height,
|
'height=%s, txn ids=%s', data, self.new_height,
|
||||||
self.block_txn_ids)
|
self.block_txn_ids)
|
||||||
logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height)
|
|
||||||
|
|
||||||
if self.events_queue:
|
if self.events_queue:
|
||||||
event = Event(EventTypes.BLOCK_VALID, {
|
event = Event(EventTypes.BLOCK_VALID, {
|
||||||
|
|||||||
@ -11,8 +11,6 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
DEFAULT_LOG_DIR = os.getcwd()
|
DEFAULT_LOG_DIR = os.getcwd()
|
||||||
BENCHMARK_LOG_LEVEL = 15
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_LOGGING_CONFIG = {
|
DEFAULT_LOGGING_CONFIG = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
@ -29,11 +27,6 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) '
|
'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) '
|
||||||
'%(message)s (%(processName)-10s - pid: %(process)d)'),
|
'%(message)s (%(processName)-10s - pid: %(process)d)'),
|
||||||
'datefmt': '%Y-%m-%d %H:%M:%S',
|
'datefmt': '%Y-%m-%d %H:%M:%S',
|
||||||
},
|
|
||||||
'benchmark': {
|
|
||||||
'class': 'logging.Formatter',
|
|
||||||
'format': ('%(asctime)s, %(levelname)s, %(message)s'),
|
|
||||||
'datefmt': '%Y-%m-%d %H:%M:%S',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'handlers': {
|
'handlers': {
|
||||||
@ -59,31 +52,15 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
'backupCount': 5,
|
'backupCount': 5,
|
||||||
'formatter': 'file',
|
'formatter': 'file',
|
||||||
'level': logging.ERROR,
|
'level': logging.ERROR,
|
||||||
},
|
|
||||||
'benchmark': {
|
|
||||||
'class': 'logging.handlers.RotatingFileHandler',
|
|
||||||
'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-benchmark.log'),
|
|
||||||
'mode': 'w',
|
|
||||||
'maxBytes': 209715200,
|
|
||||||
'backupCount': 5,
|
|
||||||
'formatter': 'benchmark',
|
|
||||||
'level': BENCHMARK_LOG_LEVEL,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'loggers': {},
|
'loggers': {},
|
||||||
'root': {
|
'root': {
|
||||||
'level': logging.DEBUG,
|
'level': logging.DEBUG,
|
||||||
'handlers': ['console', 'file', 'errors', 'benchmark'],
|
'handlers': ['console', 'file', 'errors'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def benchmark(self, message, *args, **kws):
|
|
||||||
# Yes, logger takes its '*args' as 'args'.
|
|
||||||
if self.isEnabledFor(BENCHMARK_LOG_LEVEL):
|
|
||||||
self._log(BENCHMARK_LOG_LEVEL, message, args, **kws)
|
|
||||||
|
|
||||||
|
|
||||||
def _normalize_log_level(level):
|
def _normalize_log_level(level):
|
||||||
try:
|
try:
|
||||||
return level.upper()
|
return level.upper()
|
||||||
@ -104,11 +81,6 @@ def setup_logging():
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Add a new logging level for logging benchmark
|
|
||||||
logging.addLevelName(BENCHMARK_LOG_LEVEL, 'BENCHMARK')
|
|
||||||
logging.BENCHMARK = BENCHMARK_LOG_LEVEL
|
|
||||||
logging.Logger.benchmark = benchmark
|
|
||||||
|
|
||||||
logging_configs = DEFAULT_LOGGING_CONFIG
|
logging_configs = DEFAULT_LOGGING_CONFIG
|
||||||
new_logging_configs = bigchaindb.config['log']
|
new_logging_configs = bigchaindb.config['log']
|
||||||
|
|
||||||
@ -127,7 +99,6 @@ def setup_logging():
|
|||||||
if 'level_logfile' in new_logging_configs:
|
if 'level_logfile' in new_logging_configs:
|
||||||
level = _normalize_log_level(new_logging_configs['level_logfile'])
|
level = _normalize_log_level(new_logging_configs['level_logfile'])
|
||||||
logging_configs['handlers']['file']['level'] = level
|
logging_configs['handlers']['file']['level'] = level
|
||||||
logging_configs['handlers']['benchmark']['level'] = level
|
|
||||||
|
|
||||||
if 'fmt_console' in new_logging_configs:
|
if 'fmt_console' in new_logging_configs:
|
||||||
fmt = new_logging_configs['fmt_console']
|
fmt = new_logging_configs['fmt_console']
|
||||||
|
|||||||
@ -25,7 +25,6 @@ please refer to [MongoDB docs](https://docs.mongodb.com/v3.6/tutorial/rotate-log
|
|||||||
Log rotation is baked into BigchainDB server using the `logging` module. BigchainDB server logs information into the following files:
|
Log rotation is baked into BigchainDB server using the `logging` module. BigchainDB server logs information into the following files:
|
||||||
- `bigchaindb.log`
|
- `bigchaindb.log`
|
||||||
- `bigchaindb-errors.log`
|
- `bigchaindb-errors.log`
|
||||||
- `bigchaindb-benchmark.log`
|
|
||||||
|
|
||||||
These log files are created by default in the directory from where you run `bigchaindb start`, if you are using `monit`, from
|
These log files are created by default in the directory from where you run `bigchaindb start`, if you are using `monit`, from
|
||||||
[How to Set Up a BigchainDB Network](../simple-deployment-template/network-setup.md) guide, the default directory is: `$HOME/.bigchaindb-monit/logs`
|
[How to Set Up a BigchainDB Network](../simple-deployment-template/network-setup.md) guide, the default directory is: `$HOME/.bigchaindb-monit/logs`
|
||||||
|
|||||||
@ -292,7 +292,7 @@ defined by [Python](https://docs.python.org/3.6/library/logging.html#levels),
|
|||||||
but case-insensitive for the sake of convenience:
|
but case-insensitive for the sake of convenience:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
"critical", "error", "warning", "info", "benchmark", "debug", "notset"
|
"critical", "error", "warning", "info", "debug", "notset"
|
||||||
```
|
```
|
||||||
|
|
||||||
### log.level_logfile
|
### log.level_logfile
|
||||||
@ -302,7 +302,7 @@ defined by [Python](https://docs.python.org/3.6/library/logging.html#levels),
|
|||||||
but case-insensitive for the sake of convenience:
|
but case-insensitive for the sake of convenience:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
"critical", "error", "warning", "info", "benchmark", "debug", "notset"
|
"critical", "error", "warning", "info", "debug", "notset"
|
||||||
```
|
```
|
||||||
|
|
||||||
### log.datefmt_console
|
### log.datefmt_console
|
||||||
|
|||||||
6
setup.py
6
setup.py
@ -71,10 +71,6 @@ tests_require = [
|
|||||||
'tox',
|
'tox',
|
||||||
] + docs_require
|
] + docs_require
|
||||||
|
|
||||||
benchmarks_require = [
|
|
||||||
'line-profiler==1.0',
|
|
||||||
]
|
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
# TODO Consider not installing the db drivers, or putting them in extras.
|
# TODO Consider not installing the db drivers, or putting them in extras.
|
||||||
'pymongo~=3.6',
|
'pymongo~=3.6',
|
||||||
@ -144,7 +140,7 @@ setup(
|
|||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
extras_require={
|
extras_require={
|
||||||
'test': tests_require,
|
'test': tests_require,
|
||||||
'dev': dev_require + tests_require + docs_require + benchmarks_require,
|
'dev': dev_require + tests_require + docs_require,
|
||||||
'docs': docs_require,
|
'docs': docs_require,
|
||||||
},
|
},
|
||||||
package_data={'bigchaindb.common.schema': ['*.yaml']},
|
package_data={'bigchaindb.common.schema': ['*.yaml']},
|
||||||
|
|||||||
@ -108,10 +108,6 @@ def _configure_bigchaindb(request):
|
|||||||
config = config_utils.env_config(config)
|
config = config_utils.env_config(config)
|
||||||
config_utils.set_config(config)
|
config_utils.set_config(config)
|
||||||
|
|
||||||
# NOTE: since we use a custom log level
|
|
||||||
# for benchmark logging we need to setup logging
|
|
||||||
setup_logging()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def _setup_database(_configure_bigchaindb):
|
def _setup_database(_configure_bigchaindb):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user