-
Notifications
You must be signed in to change notification settings - Fork 40
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: add rust server and template code SYNC-4447 #772
base: main
Are you sure you want to change the base?
feat: add rust server and template code SYNC-4447 #772
Conversation
Appears when running the added rust tests (just the 3 that temporarily generate Rust projects to compare log output against), the CI fails due to some likely incompatibility with cargo. Think we would need to add it to the docker builds, I can go ahead and give that a shot to see if it resolves. I also used some newer Python features (match stmt) which I see isn't supported in the earlier builds, so I'll change that to simplify. Note I didn't realize until a few CI failures that the new mypy types weren't supported in older versions of Py. I've been spoiled lately. Reverted those to support the older |
a5514af
to
da0cc74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't yet do a full review, but noticed a couple of things early, so submitting them already.
}; | ||
let envelope_json = | ||
serde_json::to_string(&envelope).expect("unable to marshal payload to json."); | ||
println!("{}", envelope_json); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't just print to stdout?
Not sure what the exact plan was here, but wouldn't we want to integrate with log
? Or somehow pass a logger in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you normally output logs in Sync @taddes? It would be best to use your standard logging mechanism. We just need to make sure that this log goes to Cloud Logging in a correct format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use slog
/ slog_mozlog_json
per SecOps guidelines. I'm going to check with the team and SRE about this.
I'm not sure if in this repo you want the most agnostic approach for output (being stdout) and allowing each service to then modify the output path, however I'm happy to make whatever changes you all see fit for a general purpose rust_server implementation. I saw with the go_server
implementation, it just prints to stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to go with the approach recommended by SRE/SecOps in the template. I don't remember why Go template looks this way, maybe that's what they do in their code.
bee69a0
to
71c4f91
Compare
71c4f91
to
872e75a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this!
I added some suggestions inline. I have tested this with my suggested changes applied in a sandbox project and confirmed that the format is correct.
I still have to review the tests. We could go without adding new test yaml files, but as I mentioned earlier I'm planning to refactor and unify these outputters so this is probably fine.
Excellent @akkomar , thank you for taking the time to review and also to validate in the sandbox. I will be doing the same with my custom project that emulates the data being passed in through Sync. Given each language varies in its serialization logic and whatnot, please let me know if you find anything that warrants a change. I will be sure to do the same. I've updated the template to be compliant with MozLog (Type and Fields), removing the two We'll confer next week with any other modifications. Now that we're registered with the probe scraper, once Sync is deployed with the Glean logic we'll be able to verify the functionality. Thanks for the opportunity to contribute to your project and for all the great collaboration! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a changelog entry?
Apart from that LGTM.
@badboy if you'd like to look at the sample output I have one in a test project: https://github.com/akkomar/server-telemetry-node-poc/pull/1/files#diff-c694e95fd2dc337599b52405253edd0ffe00fa93e870cb34f36358fe17628c88
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, looks like the only unresolved comment we have is about the actual logger:
We use slog / slog_mozlog_json per SecOps guidelines. I'm going to check with the team and SRE about this.
@taddes have you checked with the team/SRE?
I'd rather have this template to use the default recommended logger that you (and others) use, so you can just drop in the generated code into your repo without modifications.
Thanks @akkomar ! Yes, we're just discussing that as slog may be overkill, but regardless we're evaluating the right approach and indeed can add that. I did make a few optimizations to our Sync implementation to make it more "rusty", which is just some minor implementation changes (using |
Ok @akkomar , in discussion with the team, we agreed stdout is ideal and we are not going to use |
7a4a514
to
be218b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @akkomar . I have some thoughts on make some things a bit more "rusty," but we can save that for a subsequent PR. That would be implementing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated code looks good to me.
I have a few stylistic nits with respect to the code, but these could also be wrapped into the followup.
…and Field changes
…og Type and Fields serialization
be218b3
to
ee668ff
Compare
Thanks @badboy & @akkomar. I made those doc changes and nits and added some extra documentation, as I did the same on our Sync side. You'll have to re-approve when you have the chance and then feel free to merge, as I am not sure I have write access to the repo. I can then in the near future file another ticket to make some optimizations if we discover some improvements from the Sync side. |
This feature adds
rust_server
as one of the glean_parser options. As part of our discussions to integrate Glean into syncstorage-rs, this is to accomplish that goal and allow for other projects to make use of the parser. The logic was modeled after thego_server
with a few minor modifications. Template file generates the metrics and events as expected. Tests were also modeled after the go style.There are a set of 3 tests that generate rust code via cargo and they pass locally, while would require a little more CI config and I wanted to discuss that with you prior, since there may be added overhead with rustup and building via cargo. Tests temporarily disabled.
Pull Request checklist
make test
runs without emitting any warningsmake lint
runs without emitting any errorsCHANGELOG.md
or an explanation of why it does not need one