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

Add process ID to server data #171

merged 1 commit into from Nov 13, 2014

Conversation

lesliev-figured
Copy link
Contributor

It's useful to report the PID of the process that raised the exception,
this commit adds it to server data so we can see it in Rollbar.

I will manually test it a little more, please don't merge until I report that it works properly.

I've only run the specs with this Ruby:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

Process.pid seems to work on one Windows computer we have here, though I don't know how universal support is or whether an exception is thrown if it is not supported. Ruby documentation says it doesn't work on all platforms.

It's useful to report the PID of the process that raised the exception,
this commit adds it to server data so we can see it in Rollbar.
@@ -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

brianr added a commit that referenced this pull request Nov 13, 2014
@brianr brianr merged commit f56cfa7 into rollbar:master Nov 13, 2014
@brianr
Copy link
Member

brianr commented Nov 13, 2014

Merged, thanks! This will be part of the next release (1.2.8).

@brianr
Copy link
Member

brianr commented Nov 13, 2014

Released in 1.2.8

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