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

feat: Add support for library instrumentation #979

Merged
merged 9 commits into from
Jun 25, 2022
Prev Previous commit
Fix test failures and add default logName for instrumentation entry
  • Loading branch information
losalex committed Jun 25, 2022
commit dc3956ceef970174133a0dca9770ae5bed231508
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Instrumentation {
public static final String INSTRUMENTATION_VERSION_KEY = "version";
public static final String JAVA_LIBRARY_NAME_PREFIX = "java";
public static final String DEFAULT_INSTRUMENTATION_VERSION = "UNKNOWN";
public static final String INSTRUMENTATION_LOG_NAME = "diagnostic-log";
public static final int MAX_DIAGNOSTIC_VALUE_LENGTH = 14;
public static final int MAX_DIAGNOSTIC_ENTIES = 3;
private static boolean instrumentationAdded = false;
Expand Down Expand Up @@ -132,14 +133,16 @@ private static LogEntry createDiagnosticEntry(
.build()))
.build();
LogEntry entry =
LogEntry.of(
JsonPayload.of(
Struct.newBuilder()
.putAllFields(
ImmutableMap.of(
DIAGNOSTIC_INFO_KEY,
Value.newBuilder().setStructValue(instrumentation).build()))
.build()));
LogEntry.newBuilder(
JsonPayload.of(
Struct.newBuilder()
.putAllFields(
ImmutableMap.of(
DIAGNOSTIC_INFO_KEY,
Value.newBuilder().setStructValue(instrumentation).build()))
.build()))
.setLogName(INSTRUMENTATION_LOG_NAME)
.build();
return entry;
}

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