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

Add process ID to server data #171

Merged
merged 1 commit into from Nov 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def server_data
}
data[:root] = configuration.root.to_s if configuration.root
data[:branch] = configuration.branch if configuration.branch
data[:pid] = Process.pid
Copy link
Member

Choose a reason for hiding this comment

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

Because of the platform uncertainty, perhaps this should be wrapped in begin/rescue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps Process.pid if Process.respond_to?(:pid) is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm, not enough not. Process.pid seems to be defined always.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docs don't say what actually happens on platforms its not supported on. Does it return nil? Does it raise? We could tack on a "rescue nil", and assume its not supported if its missing from server_data.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/ruby/ruby/blob/trunk/process.c#L7578

If defined for all platforms, I'd say it will not crash at least.

Copy link
Member

Choose a reason for hiding this comment

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

@jondeandres sounds good. Worst-ish case, it'll report an internal error, so at least there will still be some visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! Server.pid shows up in the web interface as expected. Thanks again Brian.

Copy link
Member

Choose a reason for hiding this comment

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

Great! Thanks for this PR - I'll merge as soon as the build passes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps could be very cool do something like this:

data[:process] = "#{$0} (#{Process.pid})"

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

In some other libraries (like pyrollbar) we send the process args as server.argv. Should probably stick with that here.

e.g. https://github.com/rollbar/pyrollbar/blob/master/rollbar/__init__.py#L952


data
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
end

it 'should have the correct server keys' do
payload['data'][:server].keys.should match_array([:host, :root])
payload['data'][:server].keys.should match_array([:host, :root, :pid])
end

it 'should have the correct level and message body' do
Expand Down