File tree 4 files changed +25
-6
lines changed
main/java/com/google/cloud/logging
test/java/com/google/cloud/logging
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 {
37
37
public static final String INSTRUMENTATION_NAME_KEY = "name" ;
38
38
public static final String INSTRUMENTATION_VERSION_KEY = "version" ;
39
39
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
40
43
// {x-version-update-start:google-cloud-logging:current}
41
44
public static final String DEFAULT_INSTRUMENTATION_VERSION = "3.13.0" ;
42
45
// {x-version-update-end}
@@ -233,7 +236,13 @@ public static String getLibraryVersion(Class<?> libraryClass) {
233
236
return libraryVersion ;
234
237
}
235
238
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 ) {
237
246
if (Strings .isNullOrEmpty (value ) || value .length () < MAX_DIAGNOSTIC_VALUE_LENGTH ) {
238
247
return value ;
239
248
}
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ public void testInstrumentationGenerated() {
51
51
1 ,
52
52
2 ,
53
53
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 )))));
55
58
}
56
59
57
60
@ Test
@@ -78,7 +81,9 @@ public void testInstrumentationUpdated() {
78
81
new HashSet <>(Arrays .asList (Instrumentation .JAVA_LIBRARY_NAME_PREFIX , JAVA_OTHER_NAME )),
79
82
new HashSet <>(
80
83
Arrays .asList (
81
- Instrumentation .getLibraryVersion (Instrumentation .class ), JAVA_OTHER_VERSION )));
84
+ Instrumentation .truncateValue (
85
+ Instrumentation .getLibraryVersion (Instrumentation .class )),
86
+ JAVA_OTHER_VERSION )));
82
87
}
83
88
84
89
@ Test
@@ -92,7 +97,10 @@ public void testInvalidInstrumentationRemoved() {
92
97
0 ,
93
98
1 ,
94
99
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 )))));
96
104
}
97
105
98
106
public static JsonPayload generateInstrumentationPayload (
Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ public class LoggingHandlerTest {
171
171
LogEntry .newBuilder (
172
172
InstrumentationTest .generateInstrumentationPayload (
173
173
Instrumentation .JAVA_LIBRARY_NAME_PREFIX ,
174
- Instrumentation .getLibraryVersion (Instrumentation .class )))
174
+ Instrumentation .truncateValue (
175
+ Instrumentation .getLibraryVersion (Instrumentation .class ))))
175
176
.setLogName (Instrumentation .INSTRUMENTATION_LOG_NAME )
176
177
.build ();
177
178
Original file line number Diff line number Diff line change @@ -2333,7 +2333,8 @@ private void testDiagnosticInfoGeneration(boolean addPartialSuccessOption) {
2333
2333
LogEntry .newBuilder (
2334
2334
InstrumentationTest .generateInstrumentationPayload (
2335
2335
Instrumentation .JAVA_LIBRARY_NAME_PREFIX ,
2336
- Instrumentation .getLibraryVersion (Instrumentation .class )))
2336
+ Instrumentation .truncateValue (
2337
+ Instrumentation .getLibraryVersion (Instrumentation .class ))))
2337
2338
.setLogName (Instrumentation .INSTRUMENTATION_LOG_NAME )
2338
2339
.build ();
2339
2340
WriteLogEntriesRequest request =
You can’t perform that action at this time.
0 commit comments