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 integration test
  • Loading branch information
losalex committed Jun 22, 2022
commit f8388ac7d4dda85d61b463d80424b4a63b881f44
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.google.cloud.MonitoredResource;
import com.google.cloud.logging.BaseSystemTest;
import com.google.cloud.logging.Instrumentation;
import com.google.cloud.logging.LogEntry;
import com.google.cloud.logging.LoggingHandler;
import com.google.cloud.logging.LoggingOptions;
Expand All @@ -34,6 +35,8 @@
import com.google.cloud.logging.Synchronicity;
import com.google.common.collect.ImmutableMap;
import com.google.logging.v2.LogName;
import com.google.protobuf.ListValue;
import com.google.protobuf.Value;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -82,7 +85,24 @@ public void testLoggingHandler() throws InterruptedException {
assertThat(entry.getOperation()).isNull();
assertThat(entry.getInsertId()).isNotNull();
assertThat(entry.getTimestamp()).isNotNull();
assertThat(iterator.hasNext()).isFalse();
assertThat(iterator.hasNext()).isTrue();
entry = iterator.next();
ListValue infoList =
entry
.<Payload.JsonPayload>getPayload()
.getData()
.getFieldsOrThrow(Instrumentation.DIAGNOSTIC_INFO_KEY)
.getStructValue()
.getFieldsOrThrow(Instrumentation.INSTRUMENTATION_SOURCE_KEY)
.getListValue();
for (Value val : infoList.getValuesList()) {
assertThat(
val.getStructValue()
.getFieldsOrThrow(Instrumentation.INSTRUMENTATION_NAME_KEY)
.getStringValue()
.startsWith(Instrumentation.JAVA_LIBRARY_NAME_PREFIX))
.isTrue();
}
logger.removeHandler(handler);
}

Expand Down