-
Notifications
You must be signed in to change notification settings - Fork 2
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
Process IO probe #14
Process IO probe #14
Conversation
There was a comment here right? :-) For our use case it's important that the probes don't need root permissions. It's not a design constraint to only use |
Ah yes, deleted it for a better one and forgot the latter. I'll look into it. |
Ok, pidstat version. The integration test still fails even though I'm on stable now. Same issue as with other application, can't read stdout from child in tests. So I've been playing a little with trying to pretify the code and develop some style. Some things I came up with:
Some stylistic points on the project itself:
Okthxbye, back to phoenix and elixir :-P |
Appreciate to do a review first, then I'll clean it up |
Hmm, another thing to play with is a |
I like the Responses to your other points:
This allows us to put all the implementation code for a certain os in one clear separated scope. This will be handy when we add support for more os'es. Also this crate will be a dependency for the agent which runs on multiple platforms. So it's vital that the code does compile on other platforms, even though it doesn't offer any functionality. The easiest way to do that is use an
I did that before, the disadvantage is that you can never have dynamic information in your error messages. See https://github.com/appsignal/probes/blob/master/src/memory.rs#L87 for an example. Maybe there's a smarter solution for this possible?
Indeed
I kind of like the enum based approach because it makes it very clear which types of errors are expected. Also you can use pattern matching to make sure you cover all cases. Of course at some number of expected types it becomes impractical. I'd say we leave it as is and if it turns out we end up with more than 10ish types we take another look at it? |
Makes sense!
Can't you do: const ERROR_MESSAGE: &'static str = "I did a booboo at {}";
...
Error(&format(ERROR_MESSAGE, "this one time at bandcamp"))
Love the enum approach and absolutely want to keep it. There are some errors (like with the map_err here) that are very spare / happen only at one point. So you could choose to just use the generic wrapper in the enum and not have to use the map_err to get the type chain correctly. I feel that both leave room for playing dirty/lazy, but the first is the better approach as you force preservation of the error. It doesn't feel right to add every little error to the enum, only the ones you want to give more context and/or are common to the application. |
Also, pidstat gives different names than /proc/io. Should we rename the values to something more human? |
That ends up having the same result as just inlining the string no?
Makes sense. Not against this if we find more of the less-important errors. I think at the moment we're not there yet. |
👍 |
c7de6a0
to
1691967
Compare
Suggestions? Updated the code. Integration test running pidstat still fails as the child's stdout still isn't captured in tests. Any ideas to fix that? I'd like to have this part under tests as well. I could use manual pipes instead (which I think would work as master Stdout is captured), but it's a lot more code :( |
How about read_kbs iodelay isn't in proc/io btw
Bit worried it's a (super small) blocking call. Seems instant though locally (with time) |
👍 on the names. |
|
||
pub fn read_process_io(pid: u32) -> Result<ProcessIO> { | ||
let raw = try!(run_pidstat(pid)); | ||
println!("RAW: {}", raw); |
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.
You forgot to delete this :-)
Where did you find that information about stdout capturing not working in test @timonv? |
In the test suite. It's not working (at least for a child process) |
I have the same problem with github.com/timonv/benv, but the binary works fine |
1691967
to
e686e5f
Compare
Updated. Child process stdout still an issue |
.arg("-d") | ||
.arg(format!("-p {}", pid)) | ||
.output() | ||
.map_err(|_| ProbeError::UnexpectedContent(PIDSTAT_READ_ERROR.to_string())) |
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.
Why do you not just pass the underlying error along?
A just noticed another small thing: The pid variables should be of type |
On my default Ubuntu 14.04 installation
Is there no other way to get at this information? |
Hot damnit it used to be standard. I'll take a look. |
All our 14.04 servers have pidstat. Maybe we should make |
|
It has to get the data from somewhere. Need to look into this. How far do we want to go in parsing hard to get linux data in favor of (marginal) performance? |
99e274b
to
2de44c4
Compare
Funny, had some possibly more helpful errors with 1.6 for getting that integration test to work. Will look at it tonight. |
Ok, false positive. No child stdout is still an issue. Added early return and a link to the issue in the tests. I think we need to figure something out as most probes call a child process. Apart from that, I think I'm done here. |
cc @thijsc |
We have a very similar test in another project: #[test]
fn test_hostname() {
let hostname = match Command::new("hostname").output() {
Ok(p) => {
match from_utf8(&p.stdout) {
Ok(s) => Some(s.trim().to_owned()),
Err(_) => None
}
},
Err(e) => panic!("Getting hostname failed {}", e)
}.unwrap();
assert_eq!(Ok(hostname), super::hostname());
} Not sure why this would be failing here. It looks like the issue described in rust-lang/rust#12309 is about reading stdout from the test process itself. Not stdout from |
1168fbf
to
bc6ab82
Compare
Alright cleaned up. Integration test still failing. The issue mentions tests not capturing stdout of subprocesses. |
What's the latest status here? Is this one still stuck on the test issue? |
Yep, it is |
@timonv Do you still want to finish this pull or are your priorities elsewhere at the moment? :-) |
Elsewhere! On Mon, 25 Apr 2016 at 16:50, Thijs Cadier [email protected] wrote:
|
In that case I will close this pull, we're not using this feature at the moment. |
io (in/out in bytes/ops)