Add AnalyzerOptions to Analyzer serialize / deserialize logic #597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #596
Description of changes:
This PR addresses a discrepancy when using a
FileSystemMetricsRepository
with anAnalyzer
that hasanalyzerOptions
set.Given an analyzer which has
analyzerOptions
configured:Because the
FileSystemMetricsRepository.get()
function compares the entire analyzer object, it fails to match the current analyzer (withanalyzerOptions
) to any historical metric analyzer.This issue occurs due to the following:
When the results are persisted to a
FileSystemMetricsRepository
, theAnalysisResultSerde.serialize
function does not addanalyzerOptions
to the result object.Similarly, when
AnalysisResultSerde.deserialize
pulls historic metrics from a file, it does not parseanalyzerOptions
even if they were present.This issue means that no matter how many historical metrics are in the metrics repository file, none would be matched to the current analyzer, which would result in the check failing due to insufficient historical metrics. The current workaround would be to avoid using
analyzerOptions
if usingFileSystemMetricsRepository
, or switch to usingInMemoryMetricsRepository
The fix I propose in this PR is to add the optional
AnalyzerOptions
object to the serializer and deserializer functions so that they may be persisted and fetched properly. This will enable theFileSystemMetricsRepository.get()
function to successfully compare two analyzer objects and find an exact match.Note that there is no issue using an
InMemoryMetricsRepository
as there is no serialization/deserialization happening in that case.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.