Skip to content

Add option and API to disable Sentry reporting on demand #21

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

Closed
wants to merge 2 commits into from

Conversation

Addvilz
Copy link
Contributor

@Addvilz Addvilz commented Sep 1, 2016

This PR suggests adding an option and API to disable Sentry reporting - during tests, in testing environment's etc.


This change is Reviewable

@dcramer
Copy link
Member

dcramer commented Sep 1, 2016

Would this have the same effect as simply setting the DSN to an empty value?

@Addvilz
Copy link
Contributor Author

Addvilz commented Sep 2, 2016

Likely, but I was not able to find any documentation on what effect that has on the client exactly. This has an added value of being able to disable/enable reporting temporarily - for example, for integration tests, to verify that sentry is being invoked at all times it is meant to be invoked. Plus this is isolated in the bundle and does not rely on "external" API.

Personally, I think having explicit API and flag is way better than mangling with DSN. :) What do you think?

@dcramer
Copy link
Member

dcramer commented Sep 2, 2016

In every Sentry SDK setting a falsely value for he DSN disables reporting (it's a documented standard in our spec). Because that's all this does I think we shouldn't add a duplicate path for that. There is however an argument to be made on having a flag which completely avoids even creating the integration.

@Addvilz
Copy link
Contributor Author

Addvilz commented Sep 3, 2016

You mean to not create the service in container? How do you feel would be better to approach this?

@server-may-cry
Copy link
Contributor

server-may-cry commented Sep 30, 2016

also you can simple use this

# app/config/config_test.yml
sentry:
    skip_capture:
        - "Exception"

this will prevent store of any exception that extend \Exception

@Addvilz
Copy link
Contributor Author

Addvilz commented Oct 1, 2016

Ok, closing this then.

@ryabenko-pro
Copy link

@dcramer, with all the respect, adding this option makes it look much better.
Disabling plugin and removing DSN options are two different actions. This is not explicit way and not correct, since no one will remove the string but comment it, which makes config file messy. This does not affect standards in your spec because symfony bundles and your SDKs are different things.

My car has neutral gear and I can use it when I want engine on, but car not moving. Please consider reopen this PR.

Thank you.

@dcramer
Copy link
Member

dcramer commented Apr 18, 2017

@ryabenko-pro software has nothing to do with your cars gears, and we have a standard in place for "how to disable sending errors with Sentry" that is already followed. There's little to no value in adding a second mechanism to disable Sentry just because of personal preference.

@ryabenko-pro
Copy link

Thank you @dcramer, very clear and loud.

Software and car building have a lot in common - both are usually done by engineers, but this is rather personal opinion. Personal opinion of your potential customer, btw.

@ryabenko-pro
Copy link

Here is real case - using .env provided by symfony sentry is crashing dev env, because I can't pass null there. I'm getting exception:

InvalidArgumentException in Client.php line 429:
Unsupported Sentry DSN scheme: <not set>

I've been trying following options:

# .env file
SENTRY_DSN=null
SENTRY_DSN=NULL
SENTRY_DSN=~
SENTRY_DSN=""
SENTRY_DSN=

result in same exception. I have to go and change parameters.yml content which is not really good.
Please consider providing optional, not BC breaking disable option.

Thank you.

P.S.: If you have recipe how to make it working with very standard S3 DotEnv component, I'll leave this topic.

@dcramer
Copy link
Member

dcramer commented May 28, 2017

My expectation is that SENTRY_DSN= would work. It's possible somethings wrong and thats not true. The others (barring the empty string), are not valid, as you're simply passing real values in which would be invalid DSNs.

@Jean85
Copy link
Contributor

Jean85 commented May 29, 2017

@ryabenko-pro I think that you are misusing the Symfony Dotenv component.
Are you sure that your parameters.yml isn't overwriting what you would like to do with your .env file?

@ryabenko-pro
Copy link

@dcramer, @Jean85 sorry for disturbing. Can't reproduce the issue.

I've used sentry.dsn: '%env(SENTRY_DSN)%' in parameters.yml, but had to use just sentry.dsn: ~. Now empty string and "" are working.

Anyways, thank you for your time, please disregard my previous message.

@ryabenko-pro
Copy link

ryabenko-pro commented Aug 21, 2017

So the issue was localized. Bitbucket pipeline uses image with weird feature: empty value in .env file being parsed as string with one space " " (see screenshot). Sentry thinks that a space is not empty DSN, start parsing it and throws exception "Unsupported Sentry DSN scheme: ". Locally and on qa/prod servers any amount of spaces as a value results in empty string, so issue only appears on Bitbucket pipelines. If I put valid URL as DSN value - everything works perfectly. I write to Bitbucket support.

tursa___bk-main___add-on___pipelines_ _bitbucket

@Jean85
Copy link
Contributor

Jean85 commented Aug 22, 2017

Happy to see that you resolved it!
Maybe we can throw a trim() to that value to solve this (and similar) issues?

@ryabenko-pro
Copy link

@Jean85

unfortunately I did not yet resolved it. trim would do the trick I'm sure.

@Jean85
Copy link
Contributor

Jean85 commented Aug 22, 2017

@ryabenko-pro just released the fix: https://github.com/getsentry/sentry-symfony/releases/tag/0.8.5

@ryabenko-pro
Copy link

@Jean85

Thank you very much for fix, despite the tone of my comment. I edited my comment to remove bad behaviour example.

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