Skip to content
Open
10 changes: 10 additions & 0 deletions docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,16 @@ You may define different logger objects per system but *not* per partition.
Emit a separate log record for each performance variable.
Set this option to ``true`` if you want to keep compatibility with the performance logging prior to ReFrame 4.0.

.. py:attribute:: logging.log_sanity_results

:required: No
:default: ``false``

Emit log records of sanity-only tests in the performance handlers.
It is useful when you want to send data to the `httpjson <#the-httpjson-log-handler>`__ or other performance logging backends.

.. versionadded:: 4.9

.. py:attribute:: logging.target_systems

:required: No
Expand Down
20 changes: 18 additions & 2 deletions reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,14 @@
'%FT%T%:z'
)

def log_performance(self, level, task, msg=None, multiline=False):
if self.check is None or not self.check.is_performance_check():
def log_performance(
self, level, task, msg=None, multiline=False, log_sanity=False
):
if (
self.check is None or
not self.check.is_performance_check() and
not log_sanity
):
return

_, part, env = task.testcase
Expand Down Expand Up @@ -911,6 +917,16 @@
self.extra['check_perf_unit'] = unit
self.extra['check_perf_result'] = result
self.log(level, msg)

if not self.check.perfvalues:
self.extra['check_perf_var'] = "$sanity_dummy"
self.extra['check_perf_value'] = None
self.extra['check_perf_ref'] = None
self.extra['check_perf_lower_thres'] = None
self.extra['check_perf_upper_thres'] = None
self.extra['check_perf_unit'] = None
self.extra['check_perf_result'] = None
self.log(level, msg)

Check warning on line 929 in reframe/core/logging.py

View check run for this annotation

Codecov / codecov/patch

reframe/core/logging.py#L922-L929

Added lines #L922 - L929 were not covered by tests
Comment on lines +966 to +974
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to do it a bit more native if possible. This is like we are hacking the perfvalues to make it work for logging sanity-only tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is not needed at all. It's very easy to achieve what we want by simply removing the following check:

diff --git a/reframe/core/logging.py b/reframe/core/logging.py
index e166f857b..b44b1d8d8 100644
--- a/reframe/core/logging.py
+++ b/reframe/core/logging.py
@@ -931,7 +931,7 @@ class LoggerAdapter(logging.LoggerAdapter):
         )
 
     def log_performance(self, level, task, msg=None, multiline=False):
-        if self.check is None or not self.check.is_performance_check():
+        if self.check is None:
             return
 
         _, part, env = task.testcase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think the only changes needed are the following:

  1. Remove the check above
  2. Rename the log_performance() to log_result()

The only question remaining is whether we need a configuration option for this.

else:
self.log(level, msg)

Expand Down
17 changes: 13 additions & 4 deletions reframe/frontend/executors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def __init__(self, case, listeners=None, timeout=None):
self._perflog_compat = runtime.runtime().get_option(
'logging/0/perflog_compat'
)
self._log_sanity_results = runtime.runtime().get_option(
'logging/0/log_sanity_results'
)

def duration(self, phase):
# Treat pseudo-phases first
Expand Down Expand Up @@ -525,8 +528,11 @@ def finalize(self):
self._current_stage = 'finalize'
self._notify_listeners('on_task_success')
try:
self._perflogger.log_performance(logging.INFO, self,
multiline=self._perflog_compat)
self._perflogger.log_performance(
logging.INFO, self,
multiline=self._perflog_compat,
log_sanity=self._log_sanity_results
)
except LoggingError as e:
getlogger().warning(
f'could not log performance data for {self.testcase}: {e}'
Expand All @@ -550,8 +556,11 @@ def _wait_job(job):
self._exc_info = exc_info or sys.exc_info()
self._notify_listeners(callback)
try:
self._perflogger.log_performance(logging.INFO, self,
multiline=self._perflog_compat)
self._perflogger.log_performance(
logging.INFO, self,
multiline=self._perflog_compat,
log_sanity=self._log_sanity_results
)
except LoggingError as e:
getlogger().warning(
f'could not log performance data for {self.testcase}: {e}'
Expand Down
2 changes: 2 additions & 0 deletions reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
"properties": {
"level": {"$ref": "#/defs/loglevel"},
"perflog_compat": {"type": "boolean"},
"log_sanity_results": {"type": "boolean"},
"handlers": {
"type": "array",
"items": {
Expand Down Expand Up @@ -617,6 +618,7 @@
"general/verbose": 0,
"logging/level": "undefined",
"logging/perflog_compat": false,
"logging/log_sanity_results": false,
"logging/target_systems": ["*"],
"logging/handlers": [],
"logging/handlers_perflog": [],
Expand Down
Loading