-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Bug, double conversion. #3129
Comments
@sactre that's wired ! from the source I get the same understanding than you, it should fail. However, I currently use the timestamp parameter in the log_struct function and it works like a charm. Do you have a stack trace to investigate on ? |
@Fkawala I'm seeing the same thing that @sactre sees. Specifically, if I specify a timestamp, it fails. Using a string timestamp from google.cloud import logging as google_logging
one_week_ago = datetime.utcnow() - timedelta(days=7)
one_week_ago = one_week_ago.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
logging_client = google_logging.Client(project="my-project")
logger = logging_client.logger("mobile-logger")
logger.log_text("My Logs Here", timestamp=one_week_ago) String timestamp stack trace:
Using a datetime timestamp from google.cloud import logging as google_logging
one_week_ago = datetime.utcnow() - timedelta(days=7)
logging_client = google_logging.Client(project="my-project")
logger = logging_client.logger("mobile-logger")
logger.log_text("My Logs Here", timestamp=one_week_ago) Datetime timestamp stack trace:
|
@plowman Thanks for the MRE! We observe different behaviors because I use the Methods From the docs. I understand that is it correct to convert datetime into string in Maybe a better way would be to refactor so that @daspecster Could you flag this as bug ? Could you advise me about the right way to fix that ? |
@daspecster great ! |
in #2860 line: 163, file: logging/google/cloud/logging/logger.py
the function _make_entry_resource return a resource(dict), but de timestamp element has to be a datetime not a string. Because in the next step the timestamp has a conversion from datetime to string (file: _gax.py, function: _log_entry_mapping_to_pb).
The text was updated successfully, but these errors were encountered: