-
Notifications
You must be signed in to change notification settings - Fork 29
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
WriteLogEntriesRequest API is called per a log entry #134
Comments
This library doesn't support explicit batch logic (e.g. setting your own thresholds, deciding what logs to batch). Though, I can see an implementation down the line to allow batching, where we:
*The main challenge would be creating the various limits to stay compliant to API thresholds. i.e. we may need limits on total log entry byte size, log entry count, and more similar to go This would be a breaking change, so marking this feature request as a P3 for now. In the meantime, @ikenox you may have an easier time:
|
Building off of what Nicole said, logs will only be sent in individual API calls if their severity is at or above the flushLevel (which defaults to I'm going to close this as a duplicate of #133, but feel free to re-open if you want to discuss this further! |
Please reopen, this is not a duplicate of #133. WIth #133, you can prevent flushing, but you still can't batch log entries and reduce the Log ingestion requests. The instructions link in #134 (comment) is broken, see Write structured logs instead. |
@daniel-sanche @nicoleczhu I'd like to join @hwellmann this is still a viable request. With the suggestion to adjust flushing we just postpone set of requests but it does one by one. I would expect: if it sends on flush then merge all the entries into a single one, but it looks like it doesn't work like this. Just to make it clear, by batching on logback side I'd like to see call like this https://cloud.google.com/logging/docs/reference/libraries#logging_write_log_entry-java with Would really appreciate it if you can implement this, it burns the quote |
The provided comments include somewhat different situations. I would like to try and summarize the use cases in order to identify the expected behavior. As it was mentioned the way the log entry writing is implemented depends on the way the logger synchronization is configured. If synchronization is set to Synchronicity.SYNC the collection of log entries is sent synchronously when LoggingImpl.write() is invoked. Given each call sends a single or few log entries in an event of the load test it is easy to exhaust the quota for the API calls. The referenced appender code clearly sends only one log entry. @artemptushkin and @hwellmann , reading your comments I could not understand what is a problem you report. Unless it is the same as in the issue description, can you provide a use case and reproducing steps please? |
There is the common problem relatively to logback in the issue description, but I think the reason is deeper. Consider N calls of LoggingAppender #append(ILoggingEvent e), it causes to:
I'd expect that either:
I see that LoggingImpl is in java-logging project, should we move the issue there? @minherz |
@artemptushkin you are correct for SYNC case. However, for ASYNC case the log entries will be batched following the batching configuration in gax library. It does not happened on a call to flush. The name is misleading. The flush speeds up sending collected log entries as soon as possible by the gax batching logic. For SYNC case I do not see how log aggregation can be possible. If you request SYNC but you ask to send single log entry, there is no place for aggregation. The single entry is sent as requested. Logging library and appender have the synchronization flag set to ASYNC by default. Setting it to SYNC means that a caller explicitly asked to send all log entries they provided to the logger (or appender) immediately on the call. A developer has to decide what is desired: \1 a promised API call on invocation of the logger or \2 implicit background sending which leaves places to aggregation and other optimizations. So the expectations for SYNC behavior when a single log entry is provided do not match the configured functionality. |
Sync is clear, it's just an example. Certainly, ASYNC is expected to be updated. I stand on the fact that I had behavior A on production then I debugged and found this, code confirms. Could you refer to that gax usage you're writing about?
then gax must merge log entries but I didn't see this before sending. Or, please, check the code I refer to point where I'm wrong |
The code referenced in your comments 1 and 2 shows the direct call up to the depth of 3. It does not show that asynchronous operation does not batch multiple log entries. If you are still convinced that batching in asynchronous mode does not work, please compose a minimal application that, for your opinion, demonstrates this. Thank you. |
Seems like it's enabled by default here For the history, the reference is: It's hard to debug async code, so I rely on the code and your @minherz statement. Sorry, I might was wrong with assumptions. At least this discussion satisfies the problem: there is batching that is used by grpc in gax library. I think, that it makes no sense then to update Logback with additional batching logic. As I see it's documented as well https://cloud.google.com/logging/docs/setup/java#defaults without details, but sufficient. The ticket can be closed for me so far till any other issues/evidences. |
Hi, I use this library in my GCP project App Engine application, and I found that the quota
Log ingestion requests
is easily exhausted when load testing.When a log entry is appended, the log is wrapped as singleton list, and it is passed to google-cloud-logging library.
https://github.com/googleapis/java-logging-logback/blob/master/src/main/java/com/google/cloud/logging/logback/LoggingAppender.java#L232
Finally the singleton list seems to be converted to one
WriteLogEntriesRequest
.This means one log entry causes one WriteLogEntriesRequest API call.
https://github.com/googleapis/java-logging/blob/8cbf0af1c63dd14392bd819c9a33e0141d7aad2f/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java#L510
I think it's better to support batch send option in order to reduce request number and save
Log ingestion requests
quota.Is my idea correct?
The text was updated successfully, but these errors were encountered: