Open sapsari opened 1 year ago
For context, here's the method we're talking about:
Adding an overload that would take a LoggingLevelSwitch
parameter and pass it along to Serilog is trivial. That would allow the switch to control the minimum log level of data sent to the Sentry Serilog sink.
However, that won't necessarily provide the desired effect. The MinimumBreadcrumbLevel
and MinimumEventLevel
values are also passed in the options
passed to Sentry's Init
method. Thus, changing the level via the switch would not actually change the level Sentry uses.
We would need to go further into the Sentry.Extensions.Logging
internals, and provide a mechanism to change the logging level(s) dynamically without re-initalizing the SDK. Then we could wire the switch up to that.
TBH, it's a lot of work for not a lot of value. I'll keep this on the backlog, but we'll likely not get to it any time soon. A PR would be welcome, however. Thanks.
G'Day Matt,
Hope you are well. I am new to this. I have forked the repo. You mentioned a PR would be welcome. Were referring to just adding the Overload or broader fix by going deeper into Sentry.Extensions.Logging? I would appreciate the clarification.
Thanks Andy
Hi @aiyervenkat , Matt no longer works with Sentry but I may be able to help. I'm trying to understand what the original request was for however. Sentry's Serilog integration already let's you configure a minimum event level that is used to determine whether Serilog events get passed on to Sentry or not.
What is it you'd like to do that you can't currently do with Serilog and Sentry?
Hi @aiyervenkat , Matt no longer works with Sentry but I may be able to help. I'm trying to understand what the original request was for however. Sentry's Serilog integration already let's you configure a minimum event level that is used to determine whether Serilog events get passed on to Sentry or not.
What is it you'd like to do that you can't currently do with Serilog and Sentry?
Level switches lets you modify MinimumEventLevel after initialization
Level switches lets you modify MinimumEventLevel after initialization
OK thanks @sapsari, and in what scenario(s) are you wanting to do that? Why would you want to dynamically change that threshhold?
Level switches lets you modify MinimumEventLevel after initialization
OK thanks @sapsari, and in what scenario(s) are you wanting to do that? Why would you want to dynamically change that threshhold?
I want user to enable/disable error tracking via options at runtime. App's serilog has four sinks, only sentry sink doesn't support level switches
Level switches lets you modify MinimumEventLevel after initialization
OK thanks @sapsari, and in what scenario(s) are you wanting to do that? Why would you want to dynamically change that threshhold?
I want user to enable/disable error tracking via options at runtime. App's serilog has four sinks, only sentry sink doesn't support level switches
If it's really about enable/disable does closing the SDK work as a workaround for you?
Another option might be the SetBeforeSend callback... could that work? You'd have to set a flag somewhere indicating whether error tracking was enabled and then check this flag in the BeforeSend callback. If the flag wasn't set, the callback would return null (i.e. discard the event).
Can we add LoggingLevelSwitch
to the SentrySerilogOptions?
Can we add
LoggingLevelSwitch
to the SentrySerilogOptions?
See Matt's message earlier in this thread.
Problem Statement
Due to current API design, we cannot add a Serilog level switch to Sentry sink.
I want something like this:
Either make class SentrySink public or add an additional argument (of type LoggingLevelSwitch ) to the extension methods.
Solution Brainstorm
No response