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
Next Next commit
Fix test
  • Loading branch information
losalex committed Jun 21, 2022
commit 2a597ba594a8d6f3e0e36e5c2a48b3ec348e45ba
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public void enhanceLogEntry(LogEntry.Builder builder) {

@Before
public void setUp() {
Instrumentation.setInstrumentationStatus(true);
logging = EasyMock.createMock(Logging.class);
options = EasyMock.createMock(LoggingOptions.class);
expect(options.getProjectId()).andStubReturn(PROJECT);
Expand Down Expand Up @@ -628,6 +629,29 @@ public void testRedirectToStdoutDisabled() {
System.setOut(null);
}

@Test
public void testDiagnosticInfo() {
Instrumentation.setInstrumentationStatus(false);
LogEntry json_entry =
LogEntry.newBuilder(
InstrumentationTest.generateInstrumentationPayload(
Instrumentation.JAVA_LIBRARY_NAME_PREFIX,
Instrumentation.DEFAULT_INSTRUMENTATION_VERSION))
.build();
logging.write(
ImmutableList.of(FINEST_ENTRY, json_entry),
WriteOption.logName(LOG_NAME),
WriteOption.resource(DEFAULT_RESOURCE),
WriteOption.labels(BASE_SEVERITY_MAP),
WriteOption.partialSuccess(true));
expectLastCall().once();
replay(options, logging);
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setFormatter(new TestFormatter());
handler.publish(newLogRecord(Level.FINEST, MESSAGE));
}

private void testPublishCustomResourceWithDestination(
LogEntry entry, LogDestinationName destination) {
MonitoredResource resource = MonitoredResource.of("custom", ImmutableMap.<String, String>of());
Expand Down