From 059d62acd81190489122490cc072d0d0cb5e8cd8 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 01:42:13 +0000 Subject: [PATCH 1/4] chore(main): release 3.13.6-SNAPSHOT (#1222) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please). --- google-cloud-logging-bom/pom.xml | 8 ++++---- google-cloud-logging/pom.xml | 4 ++-- .../java/com/google/cloud/logging/Instrumentation.java | 2 +- grpc-google-cloud-logging-v2/pom.xml | 4 ++-- pom.xml | 8 ++++---- proto-google-cloud-logging-v2/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/google-cloud-logging-bom/pom.xml b/google-cloud-logging-bom/pom.xml index 5edf665af..b7d83137a 100644 --- a/google-cloud-logging-bom/pom.xml +++ b/google-cloud-logging-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-logging-bom - 3.13.5 + 3.13.6-SNAPSHOT pom com.google.cloud @@ -53,17 +53,17 @@ com.google.cloud google-cloud-logging - 3.13.5 + 3.13.6-SNAPSHOT com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT diff --git a/google-cloud-logging/pom.xml b/google-cloud-logging/pom.xml index 757c7e543..85695b97c 100644 --- a/google-cloud-logging/pom.xml +++ b/google-cloud-logging/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-logging - 3.13.5 + 3.13.6-SNAPSHOT jar Google Cloud Logging https://github.com/googleapis/java-logging @@ -11,7 +11,7 @@ com.google.cloud google-cloud-logging-parent - 3.13.5 + 3.13.6-SNAPSHOT google-cloud-logging diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java index bc89f4784..3dd9ae02f 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java @@ -41,7 +41,7 @@ public final class Instrumentation { // See // https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files // {x-version-update-start:google-cloud-logging:current} - public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.5"; + public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.6-SNAPSHOT"; // {x-version-update-end} public static final String INSTRUMENTATION_LOG_NAME = "diagnostic-log"; public static final int MAX_DIAGNOSTIC_VALUE_LENGTH = 14; diff --git a/grpc-google-cloud-logging-v2/pom.xml b/grpc-google-cloud-logging-v2/pom.xml index f3fd450ad..26148d4d4 100644 --- a/grpc-google-cloud-logging-v2/pom.xml +++ b/grpc-google-cloud-logging-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT grpc-google-cloud-logging-v2 GRPC library for grpc-google-cloud-logging-v2 com.google.cloud google-cloud-logging-parent - 3.13.5 + 3.13.6-SNAPSHOT diff --git a/pom.xml b/pom.xml index c19a2113f..ad67f42ed 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-logging-parent pom - 3.13.5 + 3.13.6-SNAPSHOT Google Cloud Logging Parent https://github.com/googleapis/java-logging @@ -61,17 +61,17 @@ com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT com.google.cloud google-cloud-logging - 3.13.5 + 3.13.6-SNAPSHOT diff --git a/proto-google-cloud-logging-v2/pom.xml b/proto-google-cloud-logging-v2/pom.xml index 0e8576f84..3e3708a18 100644 --- a/proto-google-cloud-logging-v2/pom.xml +++ b/proto-google-cloud-logging-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.5 + 0.102.6-SNAPSHOT proto-google-cloud-logging-v2 PROTO library for proto-google-cloud-logging-v2 com.google.cloud google-cloud-logging-parent - 3.13.5 + 3.13.6-SNAPSHOT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 51c9503a2..4fa8be3b7 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-logging - 3.13.5 + 3.13.6-SNAPSHOT diff --git a/versions.txt b/versions.txt index 2dfc71663..6e040a664 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,6 @@ # Format: # module:released-version:current-version -google-cloud-logging:3.13.5:3.13.5 -grpc-google-cloud-logging-v2:0.102.5:0.102.5 -proto-google-cloud-logging-v2:0.102.5:0.102.5 +google-cloud-logging:3.13.5:3.13.6-SNAPSHOT +grpc-google-cloud-logging-v2:0.102.5:0.102.6-SNAPSHOT +proto-google-cloud-logging-v2:0.102.5:0.102.6-SNAPSHOT From f4c346e4a295f1e90e20e5587729e5ac06a04a7e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 7 Dec 2022 01:10:02 +0100 Subject: [PATCH 2/4] chore(deps): update dependency com.google.cloud:google-cloud-logging to v3.13.5 (#1223) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update dependency com.google.cloud:google-cloud-logging to v3.13.5 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- README.md | 6 +++--- samples/install-without-bom/pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 47a35765f..5ece49cf4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-logging - 3.13.4 + 3.13.5 ``` @@ -58,13 +58,13 @@ implementation 'com.google.cloud:google-cloud-logging' If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-logging:3.13.4' +implementation 'com.google.cloud:google-cloud-logging:3.13.5' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-logging" % "3.13.4" +libraryDependencies += "com.google.cloud" % "google-cloud-logging" % "3.13.5" ``` ## Authentication diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index c46de7848..ec1136a10 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-logging - 3.13.4 + 3.13.5 From 662a4394688661e7da2da51446cb3a73658ead62 Mon Sep 17 00:00:00 2001 From: losalex <90795544+losalex@users.noreply.github.com> Date: Tue, 6 Dec 2022 17:13:24 -0800 Subject: [PATCH 3/4] fix: Retrieving logentries pagewise always results in an exception (#1220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Retrieving logentries pagewise always results in an exception * Address PR comments * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../com/google/cloud/logging/Logging.java | 6 ++- .../com/google/cloud/logging/LoggingImpl.java | 53 +++++++++++++------ .../com/google/cloud/logging/LoggingTest.java | 16 ++++++ 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/Logging.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/Logging.java index 9d89e0eee..811f429d3 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/Logging.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/Logging.java @@ -1203,7 +1203,8 @@ ApiFuture> listMonitoredResourceDescripto * {@link EntryListOption#pageToken(String)} to specify the page token from which to start listing * entries. Use {@link EntryListOption#sortOrder(SortingField, SortingOrder)} to sort log entries * according to your preferred order (default is most-recent last). Use {@link - * EntryListOption#filter(String)} to filter listed log entries. + * EntryListOption#filter(String)} to filter listed log entries. By default a 24 hour filter is + * applied. * *

Example of listing log entries for a specific log. * @@ -1231,7 +1232,8 @@ ApiFuture> listMonitoredResourceDescripto * specify the page size. Use {@link EntryListOption#pageToken(String)} to specify the page token * from which to start listing entries. Use {@link EntryListOption#sortOrder(SortingField, * SortingOrder)} to sort log entries according to your preferred order (default is most-recent - * last). Use {@link EntryListOption#filter(String)} to filter listed log entries. + * last). Use {@link EntryListOption#filter(String)} to filter listed log entries. By default a 24 + * hour filter is applied. * *

Example of asynchronously listing log entries for a specific log. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java index e6bc7a1ec..48aca324c 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java @@ -1014,31 +1014,19 @@ static ListLogEntriesRequest listLogEntriesRequest( if (orderBy != null) { builder.setOrderBy(orderBy); } - String filter = EntryListOption.OptionType.FILTER.get(options); - // Make sure timestamp filter is either explicitly specified or we add a default - // time filter - // of 24 hours back to be inline with gcloud behavior for the same API + String filter = generateFilter(EntryListOption.OptionType.FILTER.get(options)); if (filter != null) { - if (!Ascii.toLowerCase(filter).contains("timestamp")) { - filter = - String.format( - "%s AND %s", filter, defaultTimestampFilterCreator.createDefaultTimestampFilter()); - } builder.setFilter(filter); - } else { - // If filter is not specified, default filter is looking back 24 hours in line - // with gcloud - // behavior - builder.setFilter(defaultTimestampFilterCreator.createDefaultTimestampFilter()); } - return builder.build(); } private static ApiFuture> listLogEntriesAsync( final LoggingOptions serviceOptions, final Map options) { + // Make sure to set a filter option which later can be reused in subsequent calls + final Map updatedOptions = updateFilter(options); final ListLogEntriesRequest request = - listLogEntriesRequest(serviceOptions.getProjectId(), options); + listLogEntriesRequest(serviceOptions.getProjectId(), updatedOptions); ApiFuture list = serviceOptions.getLoggingRpcV2().list(request); return transform( list, @@ -1055,7 +1043,7 @@ public AsyncPage apply(ListLogEntriesResponse listLogEntriesResponse) ? null : listLogEntriesResponse.getNextPageToken(); return new AsyncPageImpl<>( - new LogEntryPageFetcher(serviceOptions, cursor, options), cursor, entries); + new LogEntryPageFetcher(serviceOptions, cursor, updatedOptions), cursor, entries); } }); } @@ -1137,6 +1125,37 @@ public void close() throws Exception { return optionMap; } + static Map updateFilter(final Map options) { + // We should see if filter provided in otiopns have a timestamp parameter + // and if not, it should be added with further update of options map. + String existingFilter = EntryListOption.OptionType.FILTER.get(options); + String newFilter = generateFilter(existingFilter); + if (newFilter.equals(existingFilter)) { + return options; + } + // Update + Map optionsCopy = Maps.newHashMap(options); + optionsCopy.put(EntryListOption.OptionType.FILTER, newFilter); + return optionsCopy; + } + + static String generateFilter(String filter) { + String newFilter = filter; + // Make sure timestamp filter is either explicitly specified or we add a default + // time filter of 24 hours back to be inline with gcloud behavior for the same API + if (newFilter != null) { + if (!Ascii.toLowerCase(filter).contains("timestamp")) { + newFilter = + String.format( + "%s AND %s", + newFilter, defaultTimestampFilterCreator.createDefaultTimestampFilter()); + } + } else { + newFilter = defaultTimestampFilterCreator.createDefaultTimestampFilter(); + } + return newFilter; + } + @VisibleForTesting int getNumPendingWrites() { return pendingWrites.size(); diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingTest.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingTest.java index 61200c4c6..5c59c9519 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingTest.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingTest.java @@ -18,6 +18,9 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; import com.google.cloud.MonitoredResource; import com.google.cloud.logging.Logging.EntryListOption; @@ -27,6 +30,7 @@ import com.google.cloud.logging.Logging.WriteOption; import com.google.common.collect.ImmutableMap; import com.google.logging.v2.ListLogEntriesRequest; +import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -100,6 +104,18 @@ public void testEntryListOption() { "folders/test-folder"); } + @Test + public void testFilterUpdate() { + Map options = LoggingImpl.optionMap(EntryListOption.filter(FILTER)); + assertThat((String) EntryListOption.OptionType.FILTER.get(options)).isEqualTo(FILTER); + Map updated = LoggingImpl.updateFilter(options); + assertTrue(((String) EntryListOption.OptionType.FILTER.get(updated)).contains("timestamp")); + assertFalse(options == updated); + assertNotEquals(EntryListOption.OptionType.FILTER.get(updated), FILTER); + Map anotherUpdated = LoggingImpl.updateFilter(updated); + assertTrue(anotherUpdated == updated); + } + @Test public void testWriteOption() { WriteOption writeOption = WriteOption.labels(LABELS); From 1323a6db30cd1866dae24f0d420a81fac365a2c9 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:27:41 -0800 Subject: [PATCH 4/4] chore(main): release 3.13.6 (#1225) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ google-cloud-logging-bom/pom.xml | 8 ++++---- google-cloud-logging/pom.xml | 4 ++-- .../java/com/google/cloud/logging/Instrumentation.java | 2 +- grpc-google-cloud-logging-v2/pom.xml | 4 ++-- pom.xml | 8 ++++---- proto-google-cloud-logging-v2/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 6 +++--- 9 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a25e7284b..b4d82b329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [3.13.6](https://github.com/googleapis/java-logging/compare/v3.13.5...v3.13.6) (2022-12-07) + + +### Bug Fixes + +* Retrieving logentries pagewise always results in an exception ([#1220](https://github.com/googleapis/java-logging/issues/1220)) ([662a439](https://github.com/googleapis/java-logging/commit/662a4394688661e7da2da51446cb3a73658ead62)) + ## [3.13.5](https://github.com/googleapis/java-logging/compare/v3.13.4...v3.13.5) (2022-12-06) diff --git a/google-cloud-logging-bom/pom.xml b/google-cloud-logging-bom/pom.xml index b7d83137a..daaa3bcc4 100644 --- a/google-cloud-logging-bom/pom.xml +++ b/google-cloud-logging-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-logging-bom - 3.13.6-SNAPSHOT + 3.13.6 pom com.google.cloud @@ -53,17 +53,17 @@ com.google.cloud google-cloud-logging - 3.13.6-SNAPSHOT + 3.13.6 com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 diff --git a/google-cloud-logging/pom.xml b/google-cloud-logging/pom.xml index 85695b97c..7ae5f9318 100644 --- a/google-cloud-logging/pom.xml +++ b/google-cloud-logging/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-logging - 3.13.6-SNAPSHOT + 3.13.6 jar Google Cloud Logging https://github.com/googleapis/java-logging @@ -11,7 +11,7 @@ com.google.cloud google-cloud-logging-parent - 3.13.6-SNAPSHOT + 3.13.6 google-cloud-logging diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java index 3dd9ae02f..871ace744 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java @@ -41,7 +41,7 @@ public final class Instrumentation { // See // https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files // {x-version-update-start:google-cloud-logging:current} - public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.6-SNAPSHOT"; + public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.6"; // {x-version-update-end} public static final String INSTRUMENTATION_LOG_NAME = "diagnostic-log"; public static final int MAX_DIAGNOSTIC_VALUE_LENGTH = 14; diff --git a/grpc-google-cloud-logging-v2/pom.xml b/grpc-google-cloud-logging-v2/pom.xml index 26148d4d4..9997d8842 100644 --- a/grpc-google-cloud-logging-v2/pom.xml +++ b/grpc-google-cloud-logging-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 grpc-google-cloud-logging-v2 GRPC library for grpc-google-cloud-logging-v2 com.google.cloud google-cloud-logging-parent - 3.13.6-SNAPSHOT + 3.13.6 diff --git a/pom.xml b/pom.xml index ad67f42ed..1cdb899a8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-logging-parent pom - 3.13.6-SNAPSHOT + 3.13.6 Google Cloud Logging Parent https://github.com/googleapis/java-logging @@ -61,17 +61,17 @@ com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 com.google.api.grpc grpc-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 com.google.cloud google-cloud-logging - 3.13.6-SNAPSHOT + 3.13.6 diff --git a/proto-google-cloud-logging-v2/pom.xml b/proto-google-cloud-logging-v2/pom.xml index 3e3708a18..065dcb05e 100644 --- a/proto-google-cloud-logging-v2/pom.xml +++ b/proto-google-cloud-logging-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-logging-v2 - 0.102.6-SNAPSHOT + 0.102.6 proto-google-cloud-logging-v2 PROTO library for proto-google-cloud-logging-v2 com.google.cloud google-cloud-logging-parent - 3.13.6-SNAPSHOT + 3.13.6 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 4fa8be3b7..9dce4a661 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-logging - 3.13.6-SNAPSHOT + 3.13.6 diff --git a/versions.txt b/versions.txt index 6e040a664..91bfdf6a7 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,6 @@ # Format: # module:released-version:current-version -google-cloud-logging:3.13.5:3.13.6-SNAPSHOT -grpc-google-cloud-logging-v2:0.102.5:0.102.6-SNAPSHOT -proto-google-cloud-logging-v2:0.102.5:0.102.6-SNAPSHOT +google-cloud-logging:3.13.6:3.13.6 +grpc-google-cloud-logging-v2:0.102.6:0.102.6 +proto-google-cloud-logging-v2:0.102.6:0.102.6