Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hackademy - BigQuery client example
final List<Map<String, Object>> rowValues = new ArrayList<>(logsSharedObject.getItems().size());
for (final ObjectVar itemOV : logsSharedObject.getItems()) {
final Map<String, Object> item = new HashMap<>();
rowValues.add(item);
item.put("User", clientUserId);
item.put("Timestamp", time);
item.put("Device", device);
item.put("Type", itemOV.getString("t"));
item.put("Context", clientContext);
item.put("Log", itemOV.getString("l"));
item.put("Stack", itemOV.getString("s"));
item.put("RemoteAddress", remoteAddress);
}
if (!rowValues.isEmpty()) {
try {
BigQueryServerFactory.instance().getBigQueryClientFactory().insertRows("Audit", "ClientLog", rowValues);
} catch (final Throwable _throwable) {
log.log(Level.WARNING, "Problems sending logs to BigQuery: " + _throwable.getMessage(), _throwable);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment