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

Add requestId field to response_bodies tables #86

Merged
merged 1 commit into from
Aug 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ public void processElement(ProcessContext c) {
resourceUrl = "";
}

String requestId;
if (req.has("_request_id")) {
requestId = req.get("_request_id").textValue();
} else if (req.has("_id")) {
requestId = req.get("_id").textValue();
} else if (req.has("_raw_id")) {
requestId = req.get("_raw_id").textValue();
} else {
requestId = "";
}

ObjectNode resp = (ObjectNode) req.get("response");
ObjectNode content = (ObjectNode) resp.get("content");

Expand All @@ -335,7 +346,8 @@ public void processElement(ProcessContext c) {
.set("page", pageUrl)
.set("url", resourceUrl)
.set("body", rsp.body)
.set("truncated", rsp.truncated);
.set("truncated", rsp.truncated)
.set("requestId", requestId);

String bodyJSON = MAPPER.writeValueAsString(body);
Integer recordSize = bodyJSON.getBytes("UTF-8").length;
Expand Down Expand Up @@ -507,7 +519,9 @@ public Integer apply(GcsPath path) {
body.add(new TableFieldSchema().setName("body").setType("STRING")
.setDescription("Body of the response"));
body.add(new TableFieldSchema().setName("truncated").setType("BOOLEAN")
.setDescription("Flag is true if body is >2MB"));
.setDescription("Flag is true if body is >100MB"));
body.add(new TableFieldSchema().setName("requestId").setType("STRING")
.setDescription("Corresponding _request_id property from the requests payload"));
TableSchema bodySchema = new TableSchema().setFields(body);

PCollection<TableRow> bodies = results.get(BigQueryImport.BODIES_TAG);
Expand Down