-
Notifications
You must be signed in to change notification settings - Fork 369
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
Make it easy to not use Stackdriver diagnostics in development #3335
Comments
How about having a boolean environment variable, like STACKDRIVER_BACKEND_LOGGING_OVERRIDE? And the behavior would be:
This can apply to tracing and error reporting in the same way. |
I'd prefer to have it in the options. Environment variables feel a little too invisible to me. Is there a specific benefit you're thinking of? |
Yes. The goal (in my opinion) is to reach the state of "write once, run everywhere" - The same code works without developer changes in the code . It's the config that drives the decision of in which environment the code is executed. Curious to hear more thoughts on this. |
No need for any code if the user doesn't want to have it:
|
Note that a |
@henkmollema hi! Any thoughts on this? I might start working on it soon and would like to hear your take on it. As per the environment variable vs. options, my two cents here. I tend to prefer the options as well, I see env variables as "too decoupled" from development. And:
|
Closing having moved this to the backlog. |
Often when developing an app, you really don't want all the logging to go to Stackdriver - you only want it locally.
That's easy enough to handle if you're in Startup.cs - you can use
env.IsDevelopment()
etc. But if you're just callingUseGoogleDiagnostics
, that isn't an option.It turns out we do have access to the hosting environment by the time we register the loggers etc, so this is easy enough to do - but it needs to be configurable. (If you're trying to diagnose why Stackdriver Logging isn't working, you really do want to log to Stackdriver!)
I believe this would end up being a UseGoogleDiagnostics-specific option, so I'm not sure how much sense it makes to put it into LoggerOptions etc.
Ideally, we wouldn't even validate that we can get a project ID until we knew we were going to need it. So by default you'd be able to write
.UseGoogleDiagnostics()
and it would just do nothing in development and work in staging/production.All of this has got me to wondering whether adding optional LoggerOptions etc on UseGoogleDiagnostics was the right approach. @henkmollema mentioned this in a PR. I wonder whether instead we might want a
GoogleDiagnosticsOptions
which has:The retry options and buffer options would only be used where service-options weren't specified, but they'd be handy for the Cloud Run case of "don't buffer anything" or the troubleshooting case of "don't buffer or retry anything".
Obviously this would be a breaking change compared with 3.0.0-beta14, but I think that's okay, particularly if we can get to it soon.
cc @SurferJeffAtGoogle - we've talked about this before
cc @henkmollema - would love to hear your views
The text was updated successfully, but these errors were encountered: