Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,15 @@ The additional properties for the ``httpjson`` handler are the following:
A set of optional key/value pairs to be passed with each log record to the server.
These may depend on the server configuration.

.. js:attribute:: .logging[].handlers[].ignore_keys

.. object:: .logging[].handlers_perflog[].ignore_keys

:required: No
:default: ``[]``

These keys will be excluded from the log record that will be sent to the server.


The ``httpjson`` handler sends log messages in JSON format using an HTTP POST request to the specified URL.

Expand All @@ -1202,7 +1211,8 @@ An example configuration of this handler for performance logging is shown here:
'extras': {
'facility': 'reframe',
'data-version': '1.0'
}
},
'ignore_keys': ['check_perfvalues']
}


Expand Down
18 changes: 12 additions & 6 deletions reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ def _create_httpjson_handler(site_config, config_prefix):
return None

extras = site_config.get(f'{config_prefix}/extras')
return HTTPJSONHandler(url, extras)
ignore_keys = site_config.get(f'{config_prefix}/ignore_keys')
return HTTPJSONHandler(url, extras, ignore_keys)


class HTTPJSONHandler(logging.Handler):
Expand All @@ -386,20 +387,25 @@ class HTTPJSONHandler(logging.Handler):
'stack_info', 'thread', 'threadName', 'exc_text'
}

def __init__(self, url, extras=None):
def __init__(self, url, extras=None, ignore_keys=None):
super().__init__()
self._url = url
self._extras = extras
self._ignore_keys = ignore_keys

def _record_to_json(self, record):
def _can_send(key):
return not (
key.startswith('_') or key in HTTPJSONHandler.LOG_ATTRS
or (self._ignore_keys and key in self._ignore_keys)
)

json_record = {
k: v for k, v in record.__dict__.items()
if not (k.startswith('_') or k in HTTPJSONHandler.LOG_ATTRS)
k: v for k, v in record.__dict__.items() if _can_send(k)
}
if self._extras:
json_record.update({
k: v for k, v in self._extras.items()
if not (k.startswith('_') or k in HTTPJSONHandler.LOG_ATTRS)
k: v for k, v in self._extras.items() if _can_send(k)
})

return _xfmt(json_record).encode('utf-8')
Expand Down
2 changes: 1 addition & 1 deletion reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def main():
envvar='RFM_IGNORE_REQNODENOTAVAIL',
configvar='schedulers/ignore_reqnodenotavail',
action='store_true',
help='Graylog server address'
help='Ignore ReqNodeNotAvail Slurm error'
)
argparser.add_argument(
dest='dump_pipeline_progress',
Expand Down
7 changes: 6 additions & 1 deletion reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@
{
"properties": {
"url": {"type": "string"},
"extras": {"type": "object"}
"extras": {"type": "object"},
"ignore_keys": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["url"]
}
Expand Down Expand Up @@ -546,6 +550,7 @@
"logging/handlers*/filelog_basedir": "./perflogs",
"logging/handlers*/graylog_extras": {},
"logging/handlers*/httpjson_extras": {},
"logging/handlers*/httpjson_ignore_keys": [],
"logging/handlers*/stream_name": "stdout",
"logging/handlers*/syslog_socktype": "udp",
"logging/handlers*/syslog_facility": "user",
Expand Down