-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Add overload to the public API to take Action<Scope> #675
Comments
Suggestion to tackle this:
The goal is to verify the effort to adding the thing and the impact in the API. Please also add to the docs: https://github.com/getsentry/develop |
We just updated to Sentry 3.14.1 and changed from SentrySdk.WithScope(scope =>
{
scope.SetTag("ATag", "This is a tag");
scope.SetExtra("extra", "This is extra");
_logger.LogWarning("Printing a warning in the console and logging to Sentry");
});
How do we do that with the new API? |
You can use: sentry-dotnet/src/Sentry/SentrySdk.cs Lines 337 to 338 in c6a660b
Please let us know if you have problems so we can reopen |
Thanks for the reply! I still can't make it work. Here is the background, we have a generic host that initializes Sentry with the code below (as shown in the generic host sample). .ConfigureLogging((hostContext, logging) =>
{
logging.ClearProviders();
logging.AddSimpleConsole();
logging.AddSentry(options =>
{
options.Environment = hostContext.HostingEnvironment.EnvironmentName;
options.ConfigureScope(scope =>
{
scope.SetTag("SomeTag", "TagValue");
scope.SetExtras("Extra", "extra extra");
});
hostContext.Configuration.GetSection("Sentry").Bind(options);
});
} I run this code logger.LogWarning("LOG THIS");
Sentry.SentrySdk.CaptureMessage("TEST2", scope =>
{
scope.SetTag("ThisTag", "Testing");
scope.SetExtra("No", "console log");
}, Sentry.SentryLevel.Warning); The The I might have missed something, but I don't know what. |
On the
IHub
methods likeCaptureEvent
,CaptureMessage
andCaptureException
should have an overload that takes:Action<Scope>
.The implementation should do what
WithScope
does, it pushes a scope, and passes the instance to the callback to be mutated. The result is then applied (normal code path ofCaptureEvent(event, scope)
.This serves as a replacement to the api:
This exists on
sentry-cocoa
:https://github.com/getsentry/sentry-cocoa/blob/29d1e9f2353f1a9514b2549b1de56e83f136658d/Sources/Sentry/SentrySDK.m#L146-L151
The text was updated successfully, but these errors were encountered: