We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug StackdriverJsonLayout sets value of 'timestampNanos' log field as TimeUnit.MILLISECONDS.toNanos(event.getTimeStamp() % 1_000) which has precision of miliseconds. https://github.com/GoogleCloudPlatform/spring-cloud-gcp/blob/main/spring-cloud-gcp-logging/src/main/java/com/google/cloud/spring/logging/StackdriverJsonLayout.java#L276 Proper value should be event.getNanoseconds()
TimeUnit.MILLISECONDS.toNanos(event.getTimeStamp() % 1_000)
event.getNanoseconds()
This is causing out-of-order logs in GCP Logs Explorer in some cases.
Sample
Logger log = LoggerFactory.getLogger(GenericSpringBootApplication.class); log.info("1"); log.info("2"); log.info("3"); log.info("4"); log.info("5");
Result in kubectl logs:
{"timestampSeconds":1688547662,"timestampNanos":662000000,"severity":"INFO","thread":"scheduling-1","message":"1"} {"timestampSeconds":1688547662,"timestampNanos":663000000,"severity":"INFO","thread":"scheduling-1","message":"2"} {"timestampSeconds":1688547662,"timestampNanos":663000000,"severity":"INFO","thread":"scheduling-1","message":"3"} {"timestampSeconds":1688547662,"timestampNanos":663000000,"severity":"INFO","thread":"scheduling-1","message":"4"} {"timestampSeconds":1688547662,"timestampNanos":663000000,"severity":"INFO","thread":"scheduling-1","message":"5"}
Result in GCP Logs Explorer:
The text was updated successfully, but these errors were encountered:
Would you mind submitted a fix?
Sorry, something went wrong.
fix: timestampNanos field with nanos precision (#2012)
2a4c14a
Fixes: #1996
Successfully merging a pull request may close this issue.
Describe the bug
StackdriverJsonLayout sets value of 'timestampNanos' log field as
TimeUnit.MILLISECONDS.toNanos(event.getTimeStamp() % 1_000)
which has precision of miliseconds.https://github.com/GoogleCloudPlatform/spring-cloud-gcp/blob/main/spring-cloud-gcp-logging/src/main/java/com/google/cloud/spring/logging/StackdriverJsonLayout.java#L276
Proper value should be
event.getNanoseconds()
This is causing out-of-order logs in GCP Logs Explorer in some cases.
Sample
Result in kubectl logs:
Result in GCP Logs Explorer:
The text was updated successfully, but these errors were encountered: