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
Print instrumentation record only once
  • Loading branch information
losalex committed Jun 17, 2022
commit 09b308f75e4193f50797f394418235f34f69179b
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public class Instrumentation {
public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
losalex marked this conversation as resolved.
Show resolved Hide resolved
Iterable<LogEntry> logEntries) {
boolean isWritten = setInstrumentationStatus(true);
if (isWritten) return Tuple.of(false, logEntries);
List<LogEntry> entries = new ArrayList<>();
boolean isInfoAdded = false;

for (LogEntry logEntry : logEntries) {
// Check if LogEntry has a proper payload and also contains a diagnostic entry
if (logEntry.getPayload().getType() == Type.JSON
if (!isWritten
&& logEntry.getPayload().getType() == Type.JSON
&& logEntry
.<Payload.JsonPayload>getPayload()
.getData()
Expand All @@ -61,7 +63,7 @@ public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
.getFieldsOrThrow(INSTRUMENTATION_SOURCE_KEY)
.getListValue();
entries.add(createDiagnosticEntry(null, null, infoList));
isInfoAdded = isWritten = true;
isWritten = true;
} catch (Exception ex) {
System.err.println("ERROR: unexpected exception in populateInstrumentationInfo: " + ex);
}
Expand All @@ -71,9 +73,8 @@ public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
}
if (!isWritten) {
entries.add(createDiagnosticEntry(null, null, null));
isInfoAdded = true;
}
return Tuple.of(isInfoAdded, entries);
return Tuple.of(true, entries);
}

/**
Expand Down