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

PIE-178 Multiple Metrics in stdin #36

Merged
merged 4 commits into from
Dec 11, 2019

Conversation

mrzarquon
Copy link
Contributor

Before this we assumed we would receive parsable json on standard in from the metrics executable regardless of number of systems involved.

Instead it would output a json hash for each server and not attempt to combine them into a valid array. This converts any hash received on STDIN into an array of hashes (even if its just an array of 1).

Before this we assumed we would receive parsable json on standard in from the metrics executable regardless of number of systems involved.

Instead it would output a json hash for each server and not attempt to combine them into a valid array. This converts any hash received on STDIN into an array of hashes (even if its just an array of 1).
@mrzarquon mrzarquon requested a review from a team as a code owner December 6, 2019 16:49
@@ -57,9 +57,15 @@ def upload_report(data, _sourcetype)
end

def main
data = JSON.parse(STDIN.read)
datainput = STDIN.read
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the string read in from STDIN always going to be in the right format? Do we have to wrap this in a rescue block to catch a ruby exception on bad input?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest commit adds a rescue block if we don't get anything on stdin, also checking that we get valid json before beginning to do anything else, so we can inform users of basic error states

Chris Barker added 2 commits December 11, 2019 12:15
We know we might not get valid json all the time, but we should be getting something.
Also is more explicit about which exceptions we're handling (standard)
@bmjen bmjen merged commit 4f4aa64 into puppetlabs:master Dec 11, 2019
@gsparks gsparks added the bugfix label May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants