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

Timestamp Precision #598

Closed
dansiviter opened this issue Jul 29, 2021 · 4 comments · Fixed by #654
Closed

Timestamp Precision #598

dansiviter opened this issue Jul 29, 2021 · 4 comments · Fixed by #654
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API. lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@dansiviter
Copy link

Is your feature request related to a problem? Please describe.
Although the underlying com.google.logging.v2.LogEntry supports timestamps with nanosecond precision, com.google.cloud.logging.LogEntry only supports millisecond truncating the data.

Describe the solution you'd like
Replace the current long value representing milliseconds with com.google.cloud.Timestamp.

Describe alternatives you've considered
The only way is to use the protobuf classes directly or using ReST API which is cumbersome.

Additional context
N/A

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Jul 29, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jul 30, 2021
@minherz minherz assigned minherz and unassigned simonz130 Aug 1, 2021
@minherz minherz added lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Aug 1, 2021
@minherz
Copy link
Contributor

minherz commented Aug 1, 2021

Hello,
The logging library uses gRPC API to call Logging APIs. The value is returned as com.google.protobuf.Timestamp and not com.google.cloud.Timestamp.
We would like to follow Java convention in representing time which is either using long number of milliseconds or using java.sql.Timestamps. We will check options to use timestamp with nanosecond resolutions for Timestamp and ReceiveTimestamp fields without having breaking changes in the library.

@dansiviter
Copy link
Author

java.time.Instant would be more suitable, but it seems all the Google API libraries are linked to Java 1.7.

@minherz
Copy link
Contributor

minherz commented Aug 12, 2021

Thank you, @dansiviter

@minherz
Copy link
Contributor

minherz commented Aug 12, 2021

We will implement the change for timestamp and receiveTimestamp fields in the LogEntry class to support the legacy value in milliseconds (as long) and new value of the type java.time.Instant (thanx to the recent migration to Java 8). The legacy field will be marked for deprecation and will return the value of the java.time.Instant.toEpochMilli().

minherz added a commit that referenced this issue Sep 1, 2021
Fix #598

Changing timestamp type to java.time.Instant to support nanosec resolution.
Keeping current get/set methods to operate with milliseconds.
Updating unit tests to reflect type change and additional API.
minherz added a commit that referenced this issue Sep 2, 2021
Changes timestamp type to java.time.Instant to support nanosec resolution.
Keeps current get/set methods to operate with milliseconds.
Updates unit tests to reflect type change and additional API.

Fixes #598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. lang: java Issues specific to Java. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants