File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed
main/java/com/google/cloud/logging
test/java/com/google/cloud/logging Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ public final class Instrumentation {
3737 public static final String INSTRUMENTATION_NAME_KEY = "name" ;
3838 public static final String INSTRUMENTATION_VERSION_KEY = "version" ;
3939 public static final String JAVA_LIBRARY_NAME_PREFIX = "java" ;
40+ // Using release-please annotations to update DEFAULT_INSTRUMENTATION_VERSION with latest version.
41+ // See
42+ // https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files
4043 // {x-version-update-start:google-cloud-logging:current}
4144 public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.0" ;
4245 // {x-version-update-end}
@@ -233,7 +236,13 @@ public static String getLibraryVersion(Class<?> libraryClass) {
233236 return libraryVersion ;
234237 }
235238
236- private static String truncateValue (String value ) {
239+ /**
240+ * Trancates given string to MAX_DIAGNOSTIC_VALUE_LENGTH and adds "*" instead of reduced suffix
241+ *
242+ * @param value {String} Value to be truncated
243+ * @return The truncated string
244+ */
245+ public static String truncateValue (String value ) {
237246 if (Strings .isNullOrEmpty (value ) || value .length () < MAX_DIAGNOSTIC_VALUE_LENGTH ) {
238247 return value ;
239248 }
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ public void testInstrumentationGenerated() {
5151 1 ,
5252 2 ,
5353 new HashSet <>(Arrays .asList (Instrumentation .JAVA_LIBRARY_NAME_PREFIX )),
54- new HashSet <>(Arrays .asList (Instrumentation .getLibraryVersion (Instrumentation .class ))));
54+ new HashSet <>(
55+ Arrays .asList (
56+ Instrumentation .truncateValue (
57+ Instrumentation .getLibraryVersion (Instrumentation .class )))));
5558 }
5659
5760 @ Test
@@ -78,7 +81,9 @@ public void testInstrumentationUpdated() {
7881 new HashSet <>(Arrays .asList (Instrumentation .JAVA_LIBRARY_NAME_PREFIX , JAVA_OTHER_NAME )),
7982 new HashSet <>(
8083 Arrays .asList (
81- Instrumentation .getLibraryVersion (Instrumentation .class ), JAVA_OTHER_VERSION )));
84+ Instrumentation .truncateValue (
85+ Instrumentation .getLibraryVersion (Instrumentation .class )),
86+ JAVA_OTHER_VERSION )));
8287 }
8388
8489 @ Test
@@ -92,7 +97,10 @@ public void testInvalidInstrumentationRemoved() {
9297 0 ,
9398 1 ,
9499 new HashSet <>(Arrays .asList (Instrumentation .JAVA_LIBRARY_NAME_PREFIX )),
95- new HashSet <>(Arrays .asList (Instrumentation .getLibraryVersion (Instrumentation .class ))));
100+ new HashSet <>(
101+ Arrays .asList (
102+ Instrumentation .truncateValue (
103+ Instrumentation .getLibraryVersion (Instrumentation .class )))));
96104 }
97105
98106 public static JsonPayload generateInstrumentationPayload (
Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ public class LoggingHandlerTest {
171171 LogEntry .newBuilder (
172172 InstrumentationTest .generateInstrumentationPayload (
173173 Instrumentation .JAVA_LIBRARY_NAME_PREFIX ,
174- Instrumentation .getLibraryVersion (Instrumentation .class )))
174+ Instrumentation .truncateValue (
175+ Instrumentation .getLibraryVersion (Instrumentation .class ))))
175176 .setLogName (Instrumentation .INSTRUMENTATION_LOG_NAME )
176177 .build ();
177178
Original file line number Diff line number Diff line change @@ -2333,7 +2333,8 @@ private void testDiagnosticInfoGeneration(boolean addPartialSuccessOption) {
23332333 LogEntry .newBuilder (
23342334 InstrumentationTest .generateInstrumentationPayload (
23352335 Instrumentation .JAVA_LIBRARY_NAME_PREFIX ,
2336- Instrumentation .getLibraryVersion (Instrumentation .class )))
2336+ Instrumentation .truncateValue (
2337+ Instrumentation .getLibraryVersion (Instrumentation .class ))))
23372338 .setLogName (Instrumentation .INSTRUMENTATION_LOG_NAME )
23382339 .build ();
23392340 WriteLogEntriesRequest request =
You can’t perform that action at this time.
0 commit comments