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

Runtime information #564

Merged
merged 6 commits into from
Mar 15, 2018
Merged

Runtime information #564

merged 6 commits into from
Mar 15, 2018

Conversation

hjanuschka
Copy link
Contributor

@hjanuschka hjanuschka commented Mar 14, 2018

as discussed here: #562
this one adds a context containing the current php version.

running the examples/vanilla/index.php results in a exception like this:
( i wanted to upload via github (seems to 503 right now, hope they have sentry))

https://imgur.com/Hs6FDYm

i really would appreciate if we can get this in an 1.8.* release (atleast a release in a short time) - i really would love to have this in production. let me know if you need me to backport it somewhere.

@@ -884,6 +884,8 @@ public function capture($data, $stack = null, $vars = null)
if (empty($data['site'])) {
unset($data['site']);
}
$data['contexts']['runtime'] = array('version' => phpversion(), 'name' => 'php');
Copy link
Collaborator

Choose a reason for hiding this comment

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

The blank line added below this line should probably go above. Also, maybe it would be better to have the php string in uppercase. Last thing, the most important: please use the PHP_VERSION constant as it's faster because we don't have the overhead of a function call

Copy link
Member

Choose a reason for hiding this comment

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

'php' should not be uppercased as this is a value sent to the Sentry server and is reflective on the actual platform (it generally should always be lowercased)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not that I want to open a useless debate about the naming case of a string, but PHP is an acronym and I usually see it written uppercase (even in the header of the phpinfo) and honestly I find PHP 1.2.3 prettier than php 1.2.3 😄 By the way, it's not an important thing so let's go ahead

Copy link
Collaborator

Choose a reason for hiding this comment

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

That string is strictly validated on server side, so we cannot change it, see the docs about this and the related API JSON schema.
Lowercase it is then.

@hjanuschka
Copy link
Contributor Author

@ste93cry feedback adressed.

@ste93cry
Copy link
Collaborator

Thank you for the good work, patch looks good for me

Copy link
Collaborator

@stayallive stayallive left a comment

Choose a reason for hiding this comment

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

I think there might be an issue with user supplied runtime context.

@@ -885,6 +885,8 @@ public function capture($data, $stack = null, $vars = null)
unset($data['site']);
}

$data['contexts']['runtime'] = array('version' => PHP_VERSION, 'name' => 'php');
Copy link
Collaborator

@stayallive stayallive Mar 14, 2018

Choose a reason for hiding this comment

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

Shouldn't this be merged with a possible user value in the runtime context?

Also there is an extra space character before array, non-important but while you are there 😉

$events = $client->getSentEvents();
$this->assertEquals(PHP_VERSION, $events[0]['contexts']['runtime']['version']);
$event = array_pop($events);
$this->assertEquals('php', $event['contexts']['runtime']['name']);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe also add an test what happens if the context was set by an user (for the runtime) it correctly merges with our runtime context.

@hjanuschka
Copy link
Contributor Author

@stayallive feedback addressd with: 59909d7

verifies that custom contextes and runtime get merged

Copy link
Collaborator

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

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

Great work, thanks!
I would only request to add the last test, as @stayallive requested too, to test that the user is still able to override the passed values; thanks to the array_merge the code should be already ok on that respect.

* fix 5.3 array() vs []
* change array_merge order so [runtime][name|version] is overrideable
* add test for overriden runtime
@hjanuschka
Copy link
Contributor Author

hjanuschka commented Mar 15, 2018

@Jean85 thx! - added a test to verify that one can override [runtime][name] and [runtime][version]

had to change the order of the array_merge :D
also fixed tests on 5.3 :rage3: ([] vs array())

Copy link
Collaborator

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

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

LGTM now 👍

Copy link
Collaborator

@stayallive stayallive left a comment

Choose a reason for hiding this comment

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

Thank you for this! LGTM!

@stayallive stayallive merged commit 9d84277 into getsentry:master Mar 15, 2018
@hjanuschka
Copy link
Contributor Author

thx, you folks rock! 🍺

@hjanuschka
Copy link
Contributor Author

you want me to port it into 1.8 branch ? really would love to see this released.

@Jean85
Copy link
Collaborator

Jean85 commented Mar 15, 2018

@hjanuschka that's not necessary, the master branch is still for the 1.x series. The porting to that branch is done when tagging and releasing.

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.

5 participants