-
Notifications
You must be signed in to change notification settings - Fork 75
Add arity and timings for serializers to canonical log lines #306
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
Conversation
lib/pliny/helpers/serialize.rb
Outdated
| end | ||
|
|
||
| self.class.serializer_class.new(structure).serialize(data) | ||
| env['serialization_arity'] = data.respond_to?(:size) ? data.size : 1 |
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.
Can we do pliny.serialization_arity for good env hygiene?
brandur
left a comment
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.
Nice! And yeah, unfortunately I think the env is the way to go here, although my prefixing things in there we can keep it relatively well organized.
What do you think about a test on a serializer class just to verify that emits information into env in order to fulfill its contract with the log line middleware?
lib/pliny/helpers/serialize.rb
Outdated
|
|
||
| start = Time.now | ||
| serializer_class.new(structure).serialize(data).tap do | ||
| env['timing_serialization'] = (Time.now - start).to_f |
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.
And maybe pliny.serialization_timing here. We can flip the words back around when adding it to the log line.
|
@brandur updated. |
|
Thanks! Looks good to me. |
This change adds
serialization_arityandtiming_serializationto the canonical log line. I find it a little strange storing this inenv[], but don't really have better suggestions.