Environments for .NET for Android
Learn how to configure your Sentry .NET SDK to tell Sentry about your environments.
Environments tell you where an error occurred, whether that's in your production system, your staging server, or elsewhere.
Sentry automatically creates an environment when it receives an event with the environment parameter set.
Environments are case-sensitive. The environment name can't contain newlines, spaces or forward slashes, can't be the string "None", or exceed 64 characters. You can't delete environments, but you can hide them.
// Add this to the SDK initialization callback
options.Environment = "production";
// Add this to the SDK initialization callback
options.Environment = "production";
// Add this to the SDK initialization callback
options.Environment <- "production"
If you don't set it, the SDK uses SENTRY_ENVIRONMENT, the .NET host environment or a default. The Environment option describes the order.
To change the environment at runtime, set it on the scope:
SentrySdk.ConfigureScope(scope => scope.Environment = "staging");
SentrySdk.ConfigureScope(scope => scope.Environment = "staging");
SentrySdk.ConfigureScope(fun scope -> scope.Environment <- "staging")
Everything captured with that scope uses this environment, including logs, metrics, sessions, check-ins and trace propagation. Sessions and traces use the environment from when they start, so changes to Scope.Environment don't affect a session or trace that's already running.
Changed in Version 7.0.0
In earlier versions, Scope.Environment applied only to events and transactions.
Environments help you better filter issues, releases, and user feedback in the Issue Details page of sentry.io, which you learn more about in our documentation that covers using environments.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").