Enable Sentry on certain environments
See original GitHub issueI want to log to Sentry only when the environment is set to production, but with this code all exceptions are logged to Sentry in any environment… What am I missing?
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSentry(options =>
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (env == "Production")
{
options.Dsn = "DNS Key Here";
options.Environment = env;
options.IncludeRequestPayload = true;
options.IncludeActivityData = true;
}
})
.UseStartup<Startup>();
Exception
public virtual Task<List<TEntity>> GetAllAsync()
{
throw new InvalidOperationException();
return this.context.Set<TEntity>().ToListAsync();
}
And it was logged… I tried to implement something similar with a middleware in Configure method on Startup class but with no success.
Thanks in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Environments | Sentry Documentation
Sentry automatically creates environments when it receives an event with the environment tag. Environments are case sensitive. You can also create an ...
Read more >Environments for Browser JavaScript
Sentry automatically creates an environment when it receives an event with the environment parameter set. Environments are case sensitive. The environment name ...
Read more >Environment | Sentry Developer Documentation
This guide steps you through configuring a local development environment for the Sentry server on macOS and Linux. If you're using another operating...
Read more >Using Sentry.io for Local Development | Firefox Ecosystem ...
To enable sentry for local development, simply set these environment variables in your root-level .env file (that you may need to create) to...
Read more >Configuration - Sentry Developer Documentation
This document describes configuration available to the Sentry server itself. First Install During a new install, Sentry prompts first for a walkthrough of ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not setting the
DSN
means the SDK cannot initialize itself. Even if you did callInit
orAddSentry
. For ASP.NET Core and the other integration, such configuration flag exist: InitializeSdk. If you set it to false, even if the DSN is available, the integration will not attempt to initialize the SDK.So unless you call
SentrySdk.Init
yourself, the SDK will be disabled.Wouldn’t be good to have a configuration option, something like “Enabled”: true/false? Or is not setting DSN proper way how to disable sentry in appsettings?