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

Bug 1605097 - Persist X-Debug-ID header and use persisted on creation of requests #1042

Merged
merged 7 commits into from
Jul 8, 2020

Conversation

brizental
Copy link
Contributor

I tried to make this so that it is easy to persist more headers or even other types of metadata in the future.

@brizental brizental requested a review from badboy July 7, 2020 14:51
@auto-assign auto-assign bot requested a review from travis79 July 7, 2020 14:52
@@ -327,45 +346,6 @@ mod test {
assert!(!wrong_contents_file_path.exists());
}

#[test]
fn non_json_ping_body_files_are_deleted_and_ignored() {
Copy link
Contributor Author

@brizental brizental Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated. After talking to @badboy we decided to stop checking if the ping body is valid JSON. It is very unlikely that it will be, since we are the ones writing to that file. Also the ping will be rejected by the pipeline in the unlikely event it is not valid JSON.

Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc.

Code looks good, I especially like the builder pattern used.
Some inline questions.
And one more general:
We should probably have one explicit test that we write and handle that third line correctly and also handle files without that third line correctly.

Or do we by chance already have such a test?

glean-core/src/upload/directory.rs Outdated Show resolved Hide resolved
glean-core/src/upload/directory.rs Outdated Show resolved Hide resolved
glean-core/src/lib.rs Outdated Show resolved Hide resolved
glean-core/src/ping/mod.rs Outdated Show resolved Hide resolved
);
}
if let (Some(Ok(path)), Some(Ok(body)), Ok(metadata)) =
(lines.next(), lines.next(), lines.next().transpose())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, I think this is the first time I see transpose() be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, first time I use it too! It's funny that I remember what transpose does, but always have to google map and and_then.

glean-core/src/upload/directory.rs Outdated Show resolved Hide resolved
glean-core/src/upload/directory.rs Outdated Show resolved Hide resolved
let mut request = PingRequest::builder(&local_language_binding_name)
.document_id(document_id)
.path(path)
.body(body);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yey, good use of the builder pattern here!

glean-core/src/upload/request.rs Outdated Show resolved Hide resolved
Co-authored-by: Jan-Erik Rediger <badboy@archlinux.us>
@brizental
Copy link
Contributor Author

brizental commented Jul 8, 2020

We should probably have one explicit test that we write and handle that third line correctly and also handle files without that third line correctly.

Yes, I agree. I will add an explicit test. We do have a test that indirectly tests that, but it would be nicer to have one on the ping maker tests. See: https://github.com/mozilla/glean/blob/main/glean-core/src/upload/mod.rs#L949

@brizental brizental removed the request for review from travis79 July 8, 2020 09:01
@brizental brizental merged commit 347dcb8 into mozilla:main Jul 8, 2020
@brizental brizental deleted the 1605097-persist-headers branch July 8, 2020 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants