Skip to content
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

fix: Fix failing instrumentation test preventing release #1187

Merged
merged 9 commits into from
Nov 7, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ public static String getLibraryVersion(Class<?> libraryClass) {
return libraryVersion;
}

private static String truncateValue(String value) {
/**
* Trancates given string to MAX_DIAGNOSTIC_VALUE_LENGTH and adds "*" instead of reduced suffix
*
* @param value {String} Value to be truncated
* @return The truncated string
*/
public static String truncateValue(String value) {
if (Strings.isNullOrEmpty(value) || value.length() < MAX_DIAGNOSTIC_VALUE_LENGTH) {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public void testInstrumentationGenerated() {
1,
2,
new HashSet<>(Arrays.asList(Instrumentation.JAVA_LIBRARY_NAME_PREFIX)),
new HashSet<>(Arrays.asList(Instrumentation.getLibraryVersion(Instrumentation.class))));
new HashSet<>(
Arrays.asList(
Instrumentation.truncateValue(
Instrumentation.getLibraryVersion(Instrumentation.class)))));
}

@Test
Expand All @@ -78,7 +81,9 @@ public void testInstrumentationUpdated() {
new HashSet<>(Arrays.asList(Instrumentation.JAVA_LIBRARY_NAME_PREFIX, JAVA_OTHER_NAME)),
new HashSet<>(
Arrays.asList(
Instrumentation.getLibraryVersion(Instrumentation.class), JAVA_OTHER_VERSION)));
Instrumentation.truncateValue(
Instrumentation.getLibraryVersion(Instrumentation.class)),
JAVA_OTHER_VERSION)));
}

@Test
Expand All @@ -92,7 +97,10 @@ public void testInvalidInstrumentationRemoved() {
0,
1,
new HashSet<>(Arrays.asList(Instrumentation.JAVA_LIBRARY_NAME_PREFIX)),
new HashSet<>(Arrays.asList(Instrumentation.getLibraryVersion(Instrumentation.class))));
new HashSet<>(
Arrays.asList(
Instrumentation.truncateValue(
Instrumentation.getLibraryVersion(Instrumentation.class)))));
}

public static JsonPayload generateInstrumentationPayload(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public class LoggingHandlerTest {
LogEntry.newBuilder(
InstrumentationTest.generateInstrumentationPayload(
Instrumentation.JAVA_LIBRARY_NAME_PREFIX,
Instrumentation.getLibraryVersion(Instrumentation.class)))
Instrumentation.truncateValue(
Instrumentation.getLibraryVersion(Instrumentation.class))))
.setLogName(Instrumentation.INSTRUMENTATION_LOG_NAME)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,8 @@ private void testDiagnosticInfoGeneration(boolean addPartialSuccessOption) {
LogEntry.newBuilder(
InstrumentationTest.generateInstrumentationPayload(
Instrumentation.JAVA_LIBRARY_NAME_PREFIX,
Instrumentation.getLibraryVersion(Instrumentation.class)))
Instrumentation.truncateValue(
Instrumentation.getLibraryVersion(Instrumentation.class))))
.setLogName(Instrumentation.INSTRUMENTATION_LOG_NAME)
.build();
WriteLogEntriesRequest request =
Expand Down