Skip to content

Commit

Permalink
Support events emitted from daemon tasks
Browse files Browse the repository at this point in the history
Tweaks the handling of event provenance to account for events emitted from daemon tasks to avoid NullPointerException.

All credit to @mattdailis for this fix.
  • Loading branch information
David Legg authored and mattdailis committed Aug 30, 2024
1 parent a2352ae commit 3f4bf36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ private TreeMap<Duration, List<EventGraph<EventRecord>>> createSerializedTimelin
}
}
}
var activitySpanID = Optional.of(spanToActivities.get(event.provenance()).id());
var activitySpanID = Optional.ofNullable(spanToActivities.get(event.provenance())).map(ActivityInstanceId::id);
output = EventGraph.concurrently(
output,
EventGraph.atom(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -65,7 +66,7 @@ private static void batchInsertEventGraph(
statement.setString(5, causalTime);
statement.setInt(6, event.topicId());
statement.setString(7, serializedValueP.unparse(event.value()).toString());
statement.setLong(8, event.spanId().isPresent() ? event.spanId().get() : null);
statement.setObject(8, event.spanId().orElse(null), Types.INTEGER);
statement.addBatch();
}
}
Expand Down

0 comments on commit 3f4bf36

Please sign in to comment.