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(difs): Expose dif location as a URI in candidates #344

Merged
merged 14 commits into from
Jan 13, 2021
Merged

Conversation

flub
Copy link
Contributor

@flub flub commented Jan 11, 2021

This adds a "uri" field to the dif candidates info.

To do this it firstly refactors the SourceFileId into an
ObjectFileSource to provide better structure and a unified place to
add the URI.

The second commit then uses this to add to the DIF candidates. This
also needs to add insta redaction since the port number shows up in
the URI otherwise.

sentry snapshots are not affected by this as they do not enable dif candidates info.

This replaces SourceFileId with ObjectFileSource and re-structures how
this works to have more consistent handling of file sources and to
have a more consistent place to implement URI etc.
@flub flub requested a review from a team January 11, 2021 13:18
@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2021

Warnings
⚠️ Snapshot changes likely affect Sentry tests. Please check the symbolicator test suite in Sentry and update snapshots as needed.
Instructions for snapshot changes

Sentry runs a symbolicator integration test suite located at tests/symbolicator/. Changes in this PR will likely result in snapshot diffs in Sentry, which will break the master branch and in-progress PRs.

Follow these steps to update snapshots in Sentry:

  1. Check out latest Sentry master and enable the virtualenv.
  2. Stop the symbolicator devservice using sentry devservices down symbolicator.
  3. Run your development symbolicator on port 3021.
  4. Export SENTRY_SNAPSHOTS_WRITEBACK=1 and run symbolicator tests with pytest.
  5. Review snapshot changes locally, then create a PR to Sentry.
  6. Merge the Symbolicator PR, then merge the Sentry PR.

Generated by 🚫 dangerJS against c7452c5

Co-authored-by: Jan Michael Auer <mail@jauer.org>
@untitaker untitaker self-requested a review January 11, 2021 15:21
src/actors/objects/mod.rs Outdated Show resolved Hide resolved
Floris Bruynooghe added 2 commits January 12, 2021 15:21
This introduces a newtype for the URI to make functions stricter about
what they are returning.
/// not provide a hostname nor percent-encode. Use this only for diagnostics and use
/// [`FilesystemObjectFileSource::path`] if the actual file location is needed.
pub fn uri(&self) -> ObjectFileSourceURI {
format!("file:///{path}", path = self.path().display()).into()
Copy link
Member

Choose a reason for hiding this comment

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

I mean, the doc comment says its not supposed to be compliant, but do we have tests for this on windows and linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which tests do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, i know what you mean :). So we only run prod on linux and we don't even run symbolicator tests on windows (I don't think it even can run there)

Copy link
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

LGTM, final comments below.

src/services/download/http.rs Show resolved Hide resolved
src/actors/symbolication.rs Outdated Show resolved Hide resolved
}

/// Returns the URL from which to download this object file.
pub fn url(&self) -> Result<Url> {
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to make the signature Result<Url, anyhow::Error>, since it's easier to see at a glance what this returns. That said, since this is a join_url operation, can we make this return a URL-specific error? I'd rather have the caller coerce this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought our current approach was to not use custom errors unless we need to match on them?

The Result<Url> part is more just familiarity imho, once you're used to anyhow::Result it's a pretty obvious shortcut.

Copy link
Member

Choose a reason for hiding this comment

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

So if you write anyhow::Result rather than importing, I'm also fine with it 👍

Point taken, let's go with anyhow for now. I'll propose something for this in our style guide. What I've often seen the community do, is:

  • If there is a function that performs a single task, then throw the specific error for this task. For example, I/O functions should throw std::io::Error. Parse functions should throw a custom parse error.
  • For propagating, libraries should create their own error type, either with a plain ErrorKind enum or with flag getters.
  • For propagating, applications may use a boxed error such as anyhow as long as no error handling is needed.

src/types/mod.rs Outdated
///
/// [`ObjectFileSource`]: crate::services::download::ObjectFileSource
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub struct ObjectFileSourceURI(String);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would ObjectUri suffice as a shorter name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meh, doesn't really matter but mostly i think that's too short for such an auxiliary type

src/types/objects.rs Outdated Show resolved Hide resolved
src/types/objects.rs Outdated Show resolved Hide resolved
@untitaker untitaker removed their request for review January 13, 2021 11:17
Floris Bruynooghe added 4 commits January 13, 2021 12:18
@flub flub requested a review from jan-auer January 13, 2021 11:52
@flub flub merged commit f4351ab into master Jan 13, 2021
@flub flub deleted the feat/source-uri branch January 13, 2021 15:42
jan-auer added a commit that referenced this pull request Jan 13, 2021
* master:
  feat(difs): Expose dif location as a URI in candidates (#344)
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.

3 participants