Skip to content

Commit 7166cc2

Browse files
Tyrrrzbruno-garcia
andauthored
Refactor Dsn type (#532)
Co-authored-by: Bruno Garcia <[email protected]>
1 parent 709a5bb commit 7166cc2

35 files changed

+302
-394
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void Main()
7171
{
7272
using (SentrySdk.Init(o =>
7373
{
74-
o.Dsn = new Dsn("dsn");
74+
o.Dsn = "dsn";
7575
o.Proxy = new WebProxy("https://localhost:3128");
7676
}))
7777
{

benchmarks/Sentry.Benchmarks/CaptureExceptionDuplicateDetectionBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CaptureExceptionDuplicateDetectionBenchmarks
1212

1313
private static Action<SentryOptions> SharedConfig => (o =>
1414
{
15-
o.Dsn = new Dsn(Constants.ValidDsn);
15+
o.Dsn = Constants.ValidDsn;
1616
o.SentryHttpClientFactory = new FakeHttpClientFactory();
1717
});
1818

benchmarks/Sentry.Benchmarks/FakeHttpClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Sentry.Benchmarks
1010
{
1111
internal class FakeHttpClientFactory : ISentryHttpClientFactory
1212
{
13-
public HttpClient Create(Dsn dsn, SentryOptions options) => new HttpClient(new FakeMessageHandler());
13+
public HttpClient Create(SentryOptions options) => new HttpClient(new FakeMessageHandler());
1414
}
1515

1616
internal class FakeMessageHandler : HttpMessageHandler

samples/Sentry.Samples.Console.Customized/Program.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ await SentrySdk.ConfigureScopeAsync(async scope =>
9696
o.HttpProxy = null; //new WebProxy("https://localhost:3128");
9797

9898
// Example customizing the HttpClientHandlers created
99-
o.CreateHttpClientHandler = dsn => new HttpClientHandler
99+
o.CreateHttpClientHandler = () => new HttpClientHandler
100100
{
101101
ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
102102
!certificate.Archived
103103
};
104104

105105
// Access to the HttpClient created to serve the SentryClint
106-
o.ConfigureClient = (client, dsn) =>
106+
o.ConfigureClient = client =>
107107
{
108108
client.DefaultRequestHeaders.TryAddWithoutValidation("CustomHeader", new[] { "my value" });
109109
};
@@ -187,8 +187,7 @@ await SentrySdk.ConfigureScopeAsync(async scope =>
187187
SentrySdk.CaptureEvent(evt);
188188

189189
// Using a different DSN:
190-
var adminDsn = new Dsn(AdminDsn);
191-
using (var adminClient = new SentryClient(new SentryOptions { Dsn = adminDsn }))
190+
using (var adminClient = new SentryClient(new SentryOptions { Dsn = AdminDsn }))
192191
{
193192
// Make believe web framework middleware
194193
var middleware = new AdminPartMiddleware(adminClient, null);

samples/Sentry.Samples.NLog/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private static void UsingCodeConfiguration()
109109

110110
// If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If
111111
// nothing is found, SDK is disabled.
112-
o.Dsn = new Dsn(DsnSample);
112+
o.Dsn = DsnSample;
113113

114114
o.AttachStacktrace = true;
115115
o.SendDefaultPii = true; // Send Personal Identifiable information like the username of the user logged in to the device

samples/Sentry.Samples.Serilog/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private static void Main()
1818
o.MinimumBreadcrumbLevel = LogEventLevel.Debug; // Debug and higher are stored as breadcrumbs (default os Information)
1919
o.MinimumEventLevel = LogEventLevel.Error; // Error and higher is sent as event (default is Error)
2020
// If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If nothing is found, SDK is disabled.
21-
o.Dsn = new Dsn("https://[email protected]/5428537");
21+
o.Dsn = "https://[email protected]/5428537";
2222
o.AttachStacktrace = true;
2323
o.SendDefaultPii = true; // send PII like the username of the user logged in to the device
2424
// Other configuration

src/Sentry.Extensions.Logging/SentryLoggingOptions.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ public class SentryLoggingOptions : SentryOptions
4040
/// </value>
4141
public LogLevel MinimumEventLevel { get; set; } = LogLevel.Error;
4242

43-
/// <summary>
44-
/// The DSN which defines where events are sent
45-
/// </summary>
46-
public new string? Dsn
47-
{
48-
get => base.Dsn?.ToString();
49-
set
50-
{
51-
if (value != null && !Sentry.Dsn.IsDisabled(value))
52-
{
53-
base.Dsn = new Dsn(value);
54-
}
55-
}
56-
}
57-
5843
/// <summary>
5944
/// Whether to initialize this SDK through this integration
6045
/// </summary>

src/Sentry.NLog/ConfigurationExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public static LoggingConfiguration AddSentry(this LoggingConfiguration configura
9696
Layout = "${message}",
9797
};
9898

99-
if (dsn != null && options.Dsn == null)
99+
if (dsn != null && string.IsNullOrWhiteSpace(options.Dsn))
100100
{
101-
options.Dsn = new Dsn(dsn);
101+
options.Dsn = dsn;
102102
}
103103

104104
configuration.AddTarget(targetName, target);

src/Sentry.NLog/SentryTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ protected override void InitializeTarget()
274274
var customDsn = Dsn?.Render(LogEventInfo.CreateNullEvent());
275275
if (!string.IsNullOrEmpty(customDsn))
276276
{
277-
Options.Dsn = new Dsn(customDsn);
277+
Options.Dsn = customDsn;
278278
}
279279

280280
var customRelease = Release?.Render(LogEventInfo.CreateNullEvent());

src/Sentry.Serilog/SentrySinkExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public static void ConfigureSentrySerilogOptions(
186186
{
187187
if (!string.IsNullOrWhiteSpace(dsn))
188188
{
189-
sentrySerilogOptions.Dsn = new Dsn(dsn);
189+
sentrySerilogOptions.Dsn = dsn;
190190
}
191191

192192
if (minimumEventLevel.HasValue)

0 commit comments

Comments
 (0)