Skip to content

Conversation

@vkarak
Copy link
Contributor

@vkarak vkarak commented Dec 5, 2020

The implementation of the dynamic log record based on arbitrary test attributes is revised completely. It does not happen anymore in the formatter, because the formatter is not used by the Graylog handler and this was the reason for #1640. All public test attributes as well as some interesting properties are put in the logger's extra dict. This will be transferred to the log record by Python's logging mechanism. At this point, we do NOT format anything, except the check_job_completion_time, in order to be sent correctly to Graylog. The formatting of the record is an exclusive duty of the formatter object, which formats the final log message through its formatMessage() method. We don't format the record attributes directly, but we use a proxy dictionary, which holds the formatted values, in order to produce the final message from the format string. All attributes, except lists, tuples, sets and strings are formatted using our jsonext.dumps() function. For compatibility with the current behaviour, lists, tuples and sets are formatted as comma-separated lists, whereas strings are passed as-is (NB: if they were JSON formatted, they would be quoted). This allows users to use the %(check_perf_patterns)s format specifier in order to get all the performance variables and values at once as a JSON object. If a requested test attribute cannot be found, it will be logged as null.

The Graylog handler sends to the remote end the full log record converted to JSON. Again here, we use our JSON encoding method. There are some limitations to this. If a field is logged as null it will not be indexed and it will not show up in the Kibana logs. Also, for some reason that I cannot understand, the same happens for boolean fields. It would be rather complicated to format these fields as strings and transfer them, without messing with the log record, so I chose not to do it, because in principle it's not a handler's responsibility to format a log record.

Fixes #1640.

Vasileios Karakasis added 6 commits December 4, 2020 00:38
The log record extras are not formatted at all when they are defined in the
`LoggerAdapter`'s extras. They can be raw objects. Our custom formatter will
format them, but it will NOT overwrite the log record attributes with their
formatted values, so that the record contains all the information. The builtin
formatters can still work with that, except that they will use the `str()`
method to format objects.

The Graylog handler does not use a formatter by design. Instead, it encodes the
whole record object into JSON and sends it over to the Graylog server. All we do
in this case is to use our own JSON encoder, which can recognize the ReFrame
objects.
@vkarak vkarak added this to the ReFrame sprint 20.18 milestone Dec 5, 2020
@vkarak vkarak requested review from teojgo and victorusu December 5, 2020 19:37
@vkarak vkarak self-assigned this Dec 5, 2020
@codecov-io
Copy link

codecov-io commented Dec 5, 2020

Codecov Report

Merging #1644 (cfefcd0) into master (de303ea) will increase coverage by 0.02%.
The diff coverage is 96.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1644      +/-   ##
==========================================
+ Coverage   87.54%   87.57%   +0.02%     
==========================================
  Files          44       44              
  Lines        7288     7289       +1     
==========================================
+ Hits         6380     6383       +3     
+ Misses        908      906       -2     
Impacted Files Coverage Δ
reframe/utility/jsonext.py 95.23% <92.85%> (+0.23%) ⬆️
reframe/core/logging.py 84.30% <96.29%> (-0.03%) ⬇️
reframe/core/buildsystems.py 97.50% <100.00%> (+0.03%) ⬆️
reframe/core/deferrable.py 97.54% <100.00%> (+0.03%) ⬆️
reframe/core/pipeline.py 92.44% <100.00%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de303ea...cfefcd0. Read the comment docs.

Copy link
Contributor

@jgphpc jgphpc left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@teojgo teojgo left a comment

Choose a reason for hiding this comment

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

lgtm now

@vkarak vkarak merged commit dbf60bb into reframe-hpc:master Dec 7, 2020
@vkarak vkarak deleted the bugfix/graylog-handler-dynamic-extras branch December 7, 2020 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sending data to Graylog is broken

5 participants