Skip to content
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

Zero garbage serialization of ISO timestamps #77

Merged
merged 2 commits into from
May 7, 2018

Conversation

felixbarny
Copy link
Member

@felixbarny felixbarny commented May 7, 2018

Quoting the Javadoc:

/**
 * This class serializes an epoch timestamp in milliseconds to a ISO 8601 date time sting,
 * for example {@code 1970-01-01T00:00:00.000Z}
 * <p>
 * The main advantage of this class is that is able to serialize the timestamp in a garbage free way,
 * i.e. without object allocations and that it is faster than {@link java.text.DateFormat#format(Date)}.
 * </p>
 * <p>
 * The most complex part when formatting a ISO date is to determine the actual year,
 * month and date as you have to account for leap years.
 * Leveraging the fact that for a whole day this stays the same
 * and that the agent only serializes the current timestamp and not arbitrary ones,
 * we offload this task to {@link java.text.DateFormat#format(Date)} and cache the result.
 * So we only have to serialize the time part of the ISO timestamp which is easy
 * as a day has exactly {@code 1000 * 60 * 60 * 24} milliseconds.
 * Also, we don't have to worry about leap seconds when dealing with the epoch timestamp.
 * </p>
 * <p>
 * Note: this class is not thread safe.
 * As serializing the payloads is done in a single thread,
 * this is no problem though.
 * </p>
 */

@codecov-io
Copy link

Codecov Report

Merging #77 into master will increase coverage by 0.42%.
The diff coverage is 97.91%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #77      +/-   ##
============================================
+ Coverage     76.01%   76.43%   +0.42%     
- Complexity      724      737      +13     
============================================
  Files            78       79       +1     
  Lines          2643     2674      +31     
  Branches        240      241       +1     
============================================
+ Hits           2009     2044      +35     
+ Misses          501      497       -4     
  Partials        133      133
Impacted Files Coverage Δ Complexity Δ
...lastic/apm/report/serialize/DslJsonSerializer.java 84.75% <100%> (+0.1%) 78 <1> (+1) ⬆️
...o/elastic/apm/report/serialize/DateSerializer.java 100% <100%> (ø) 12 <12> (?)
...a/co/elastic/apm/impl/transaction/Transaction.java 76.34% <100%> (+2.87%) 28 <0> (ø) ⬇️
...n/java/co/elastic/apm/impl/error/ErrorCapture.java 59.09% <50%> (-1.78%) 8 <1> (ø)

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 6a3baa7...71971dc. Read the comment docs.

@felixbarny felixbarny merged commit 6ea6440 into elastic:master May 7, 2018
@felixbarny felixbarny deleted the zero-garbage-date branch May 7, 2018 10:19
@alvarolobato alvarolobato added this to the Beta milestone May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants