-
Notifications
You must be signed in to change notification settings - Fork 634
config(kayenta-core): Add KayentaSerializationConfigurationProperties #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config(kayenta-core): Add KayentaSerializationConfigurationProperties #766
Conversation
Jackson 2.10+ changes the default behaviour for serializing and Duartion from String to Timestamp. The behaviour is already being set explcitly (twice!) for Date objects, but wasn't addressed for Durations. Rather than setting this property explicitly, I added a configuration stanza to kayenta.yml to allow users to set their preferred behaviour, defaulting to the old behaviour of encoding both Date and Duration as Strings.
@@ -0,0 +1,27 @@ | |||
/* | |||
* Copyright 2017 Google, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/2017 Google/2020 Netflix
|
||
public class KayentaSerializationConfigurationProperties { | ||
|
||
@Getter @Setter private boolean writeDatesAsTimestamps = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use @Data
on the class and drop all the @Getters
and @Setters
?
@@ -58,7 +57,9 @@ class CanaryScopeSpec extends Specification { | |||
|
|||
private ObjectMapper myObjectMapper() { | |||
ObjectMapper objectMapper = new ObjectMapper(); | |||
KayentaConfiguration.configureObjectMapperFeatures(objectMapper); | |||
KayentaSerializationConfigurationProperties kayentaSerializationConfigurationProperties = new KayentaSerializationConfigurationProperties(); | |||
kayentaSerializationConfigurationProperties.setWriteDatesAsTimestamps(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the property defaults to false
, so does this setting have any effect?
Does the test fail if this property is set to true
?
I can't see how the existing tests verify that the two fields are in fact now serialized as strings. If the goal is to prevent the public-facing contract from changing unexpectedly, I don't think the tests actually do that. The I think |
I agree. I'll make it its own test outside of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
A recent change to the
springboot.jackson.ObjectMapper
's serialization behaviour changed the waycanaryDuration
is serialized in canary reports. This PR adds a configuration section to control that behaviour, and sets to default to match the behaviour before the change.Jackson 2.10+ changes the default behaviour for serializing Duration from String to Timestamp.
The behaviour is already being set explicitly for Date objects, but wasn't addressed for Duration objects.
Rather than setting this property explicitly, I added a configuration stanza to
kayenta.yml
to allow users to set their preferred behaviour, and defaulting to the old behaviour of encoding both Date and Duration as Strings.Before (with the updated serialization behaviour):
After (with
writeDurationsAsTimestamps: false
inkayenta.yml
):You can set either
Date
,Duration
, or both to be serialized as Integer milliseconds by settingin
kayenta.yml