-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Support for SENTRY_ENVIRONMENT
environment variable
#354
Conversation
This aligns the behaviour of this SDK with the PHP-SDK and makes it easier for developers to have different values for the Sentry and Laravel environments. The environment of the Laravel application is still being used as a fallback, so no breaking changes are introduced.
This way older versions of laravel are also supported
A I think this might be very specific to your application since most applications don't have another environment and/or would use tags to differentiate between tenants in a multi-tenant situation. I'm not against this change (if changed so it would work with config caching) but I'm thinking this might be a little too specific for your use case to add as a default. I might be open to add this to the |
After reading the docs and your comment a bit better. Let's add this to the default This would have to look a little something like this I think: $options = \array_merge(
[
'prefixes' => [$basePath],
'in_app_exclude' => ["{$basePath}/vendor"],
],
$userConfig
);
$options['environment'] = $options['environment'] ?? $this->app->environment(), |
You're right, I always forget about config caching and its behaviour with the I also like your suggestion, as it also improves the discoverability of this feature. Will change it soon. By the way I was a bit surprised that you still run the tests on older versions of Laravel. I first used the In the readme you state:
so why do you still run the tests for older versions on the master branch? Just asking out of curiosity. |
We still support Laravel 5.0+ and PHP 7.1+ (read the 2 lines before it) we don’t only support Laravel 7. It’s meant to say we started supporting Laravel 7 on version 1.7.0. |
This works better with config-caching than the previous approach that relied on the env-function.
Ah, thanks for the clarification, I did not read that part correctly. |
Let me know if there are still changes that need to be made, like the wording of the comment in the config file, as this is user facing. |
@NiclasvanEyk sorry, I thought you had not pushed yet 😄 I've made a few tiny adjustments to this feature, should all work the same still but possibly makes the working a bit more clear. Let me know if you think otherwise! |
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.
Thanks for making this contribution, much appreciated 👍
I'm not sure why this was never merged, thanks again! |
Motivation
By default the PHP-SDK uses the value of the
SENTRY_ENVIRONMENT
environment variable. In the Laravel-SDK this behaviour is overridden, as Laravel implements its own logic to set the environment.This makes a lot of sense, but there are certain scenarios where one might wants to have different values for the Sentry environment and the Application environment. For example the
@production
-directive for Blade can only be properly used, if you set the Laravel environment to'production'
.As an example, we often have the scenario at work, that we deploy a software release in multiple environments, but each environment runs in "production"-mode. We adjust the environment for Sentry to
'customer-abc'
,'customer-xyz'
for each deployment individually, while the Laravel environment is set to'production'
for all deployments.We do this each time, by adding
to our
config/sentry.php
-file every time, but I feel like this could be also useful for other users.Contents
This PR adjusts the defaults to respect the value of the
SENTRY_ENVIRONMENT
environment variable while still using the Laravel environment as a fallback. No breaking changes are introduced and this way this SDK behaves more like the underlying PHP-SDK.