Skip to content

Commit 15c5a85

Browse files
authored
Remove obsolete stuff (#533)
1 parent 32a3518 commit 15c5a85

File tree

11 files changed

+11
-163
lines changed

11 files changed

+11
-163
lines changed

src/Sentry.AspNetCore/SentryAspNetCoreOptions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ namespace Sentry.AspNetCore
1010
/// <inheritdoc />
1111
public class SentryAspNetCoreOptions : SentryLoggingOptions
1212
{
13-
/// <summary>
14-
/// Gets or sets a value indicating whether to [include the request payload].
15-
/// </summary>
16-
/// <value>
17-
/// <c>true</c> if [the request payload shall be included in events]; otherwise, <c>false</c>.
18-
/// </value>
19-
[Obsolete("Use MaxRequestBodySize instead.")]
20-
public bool IncludeRequestPayload
21-
{
22-
get => MaxRequestBodySize != RequestSize.None;
23-
// As originally there was no truncation, setting to Large.
24-
set => MaxRequestBodySize = value ? RequestSize.Always : RequestSize.None;
25-
}
26-
2713
/// <summary>
2814
/// Gets or sets a value indicating whether [include System.Diagnostic.Activity data] to events.
2915
/// </summary>

src/Sentry.NLog/SentryTarget.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -182,29 +182,6 @@ public bool IncludeEventPropertiesAsTags
182182
set => Options.IncludeEventPropertiesAsTags = value;
183183
}
184184

185-
/// <summary>
186-
/// Determines whether event-level properties will be sent to sentry as additional data.
187-
/// Defaults to <see langword="true" />.
188-
/// </summary>
189-
/// <seealso cref="IncludeEventPropertiesAsTags" />
190-
[Obsolete("Use IncludeEventProperties instead")]
191-
public bool SendEventPropertiesAsData
192-
{
193-
get => IncludeEventProperties;
194-
set => IncludeEventProperties = value;
195-
}
196-
197-
/// <summary>
198-
/// Determines whether event properties will be sent to sentry as Tags or not.
199-
/// Defaults to <see langword="false" />.
200-
/// </summary>
201-
[Obsolete("Use IncludeEventPropertiesAsTags instead")]
202-
public bool SendEventPropertiesAsTags
203-
{
204-
get => IncludeEventPropertiesAsTags;
205-
set => IncludeEventPropertiesAsTags = value;
206-
}
207-
208185
/// <summary>
209186
/// Determines whether or not to include event-level data as data in breadcrumbs for future errors.
210187
/// Defaults to <see langword="false" />.

src/Sentry/Internal/Http/DefaultSentryHttpClientFactory.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ namespace Sentry.Internal.Http
1212
/// <inheritdoc />
1313
internal class DefaultSentryHttpClientFactory : ISentryHttpClientFactory
1414
{
15-
private readonly Action<HttpClientHandler>? _configureHandler;
16-
private readonly Action<HttpClient>? _configureClient;
17-
18-
/// <summary>
19-
/// Creates a new instance of <see cref="DefaultSentryHttpClientFactory"/>
20-
/// </summary>
21-
/// <param name="configureHandler">An optional configuration callback</param>
22-
/// <param name="configureClient">An optional HttpClient configuration callback</param>
23-
public DefaultSentryHttpClientFactory(
24-
Action<HttpClientHandler>? configureHandler = null,
25-
Action<HttpClient>? configureClient = null)
26-
{
27-
_configureHandler = configureHandler;
28-
_configureClient = configureClient;
29-
}
30-
3115
/// <summary>
3216
/// Creates an <see cref="T:System.Net.Http.HttpClient" /> configure to call Sentry for the specified <see cref="T:Sentry.Dsn" />
3317
/// </summary>
@@ -58,12 +42,6 @@ public HttpClient Create(SentryOptions options)
5842
options.DiagnosticLogger?.LogDebug("No response compression supported by HttpClientHandler.");
5943
}
6044

61-
if (_configureHandler is { } configureHandler)
62-
{
63-
options.DiagnosticLogger?.LogDebug("Invoking user-defined HttpClientHandler configuration action.");
64-
configureHandler.Invoke(httpClientHandler);
65-
}
66-
6745
HttpMessageHandler handler = httpClientHandler;
6846

6947
if (options.RequestBodyCompressionLevel != CompressionLevel.NoCompression)
@@ -91,7 +69,7 @@ public HttpClient Create(SentryOptions options)
9169

9270
client.DefaultRequestHeaders.Add("Accept", "application/json");
9371

94-
if (_configureClient is { } configureClient)
72+
if (options.ConfigureClient is { } configureClient)
9573
{
9674
options.DiagnosticLogger?.LogDebug("Invoking user-defined HttpClient configuration action.");
9775
configureClient.Invoke(client);

src/Sentry/Internal/SdkComposer.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,14 @@ public IBackgroundWorker CreateBackgroundWorker()
3838
dsn.SecretKey
3939
);
4040

41-
if (_options.SentryHttpClientFactory is { } factory)
41+
if (_options.SentryHttpClientFactory is {})
4242
{
4343
_options.DiagnosticLogger?.LogDebug("Using ISentryHttpClientFactory set through options: {0}.",
44-
factory.GetType().Name);
45-
}
46-
else
47-
{
48-
#pragma warning disable 618 // Tests will be removed once obsolete code gets removed
49-
factory = new DefaultSentryHttpClientFactory(_options.ConfigureHandler, _options.ConfigureClient);
50-
#pragma warning restore 618
44+
_options.SentryHttpClientFactory.GetType().Name);
5145
}
5246

53-
var httpClient = factory.Create(_options);
47+
var httpClientFactory = _options.SentryHttpClientFactory ?? new DefaultSentryHttpClientFactory();
48+
var httpClient = httpClientFactory.Create(_options);
5449

5550
return new BackgroundWorker(new HttpTransport(_options, httpClient, addAuth), _options);
5651
}

src/Sentry/SentryOptions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,6 @@ public int MaxQueueItems
287287
/// </summary>
288288
public IWebProxy? HttpProxy { get; set; }
289289

290-
/// <summary>
291-
/// A callback invoked when a <see cref="SentryClient"/> is created.
292-
/// </summary>
293-
/// <remarks>
294-
/// This callback is invoked once configuration has been applied to the inner most <see cref="HttpClientHandler"/>.
295-
/// </remarks>
296-
[Obsolete("Please use '" + nameof(CreateHttpClientHandler) + "' instead. " +
297-
"You can create an instance of '" + nameof(HttpClientHandler) + "' and modify it at once.")]
298-
public Action<HttpClientHandler>? ConfigureHandler { get; set; }
299-
300290
/// <summary>
301291
/// Creates the inner most <see cref="HttpClientHandler"/>.
302292
/// </summary>

test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,15 @@ public void AllSettingsViaJson()
192192

193193
var options = ServiceProvider.GetRequiredService<IOptions<SentryAspNetCoreOptions>>().Value;
194194

195-
Assert.Equal("https://[email protected]/1", ((SentryOptions)options).Dsn.ToString());
196-
#pragma warning disable 618
197-
Assert.True(options.IncludeRequestPayload);
198-
#pragma warning restore 618
195+
Assert.Equal("https://[email protected]/1", options.Dsn);
199196
Assert.Equal(RequestSize.Always, options.MaxRequestBodySize);
200197
Assert.True(options.SendDefaultPii);
201198
Assert.True(options.IncludeActivityData);
202199
Assert.Equal(LogLevel.Error, options.MinimumBreadcrumbLevel);
203200
Assert.Equal(LogLevel.Critical, options.MinimumEventLevel);
204201
Assert.False(options.InitializeSdk);
205202
Assert.Equal(999, options.MaxBreadcrumbs);
206-
Assert.Equal(1, options.SampleRate.Value);
203+
Assert.Equal(1, options.SampleRate);
207204
Assert.Equal("7f5d9a1", options.Release);
208205
Assert.Equal("Staging", options.Environment);
209206
}

test/Sentry.AspNetCore.Tests/ScopeExtensionsTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public class ScopeExtensionsTests
2020
public SentryAspNetCoreOptions SentryAspNetCoreOptions { get; set; }
2121
= new SentryAspNetCoreOptions
2222
{
23-
#pragma warning disable 618
24-
IncludeRequestPayload = true,
25-
#pragma warning restore 618
2623
MaxRequestBodySize = RequestSize.Always
2724
};
2825

test/Sentry.AspNetCore.Tests/SentryMiddlewareTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ public void Ctor_NullHubAccessor_ThrowsArgumentNullException()
268268
[Fact]
269269
public async Task InvokeAsync_OptionsReadPayload_CanSeekStream()
270270
{
271-
#pragma warning disable 618
272-
_fixture.Options.IncludeRequestPayload = true;
273-
#pragma warning restore 618
271+
_fixture.Options.MaxRequestBodySize = RequestSize.Always;
274272
var sut = _fixture.GetSut();
275273
var request = Substitute.For<HttpRequest>();
276274
var stream = Substitute.For<Stream>();

test/Sentry.AspNetCore.Tests/allsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Sentry": {
33
"Dsn": "https://[email protected]/1",
4-
"IncludeRequestPayload": true,
4+
"MaxRequestBodySize": "Always",
55
"SendDefaultPii": true,
66
"IncludeActivityData": true,
77
"MinimumBreadcrumbLevel": "Error",

test/Sentry.Tests/Internals/DefaultSentryHttpClientFactoryTests.cs

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ private class Fixture
1818
Dsn = DsnSamples.ValidDsnWithSecret
1919
};
2020

21-
public Action<HttpClientHandler> ConfigureHandler { get; set; }
22-
public Action<HttpClient> ConfigureClient { get; set; }
23-
2421
public DefaultSentryHttpClientFactory GetSut()
25-
=> new DefaultSentryHttpClientFactory(ConfigureHandler, ConfigureClient);
22+
=> new DefaultSentryHttpClientFactory();
2623
}
2724

2825
private readonly Fixture _fixture = new Fixture();
@@ -88,45 +85,11 @@ public void Create_RetryAfterHandler_FirstHandler()
8885
Assert.Equal(typeof(RetryAfterHandler), client.GetMessageHandlers().First().GetType());
8986
}
9087

91-
[Fact]
92-
public void Create_DecompressionMethodNone_SetToClientHandler()
93-
{
94-
_fixture.HttpOptions.DecompressionMethods = DecompressionMethods.None;
95-
96-
var configureHandlerInvoked = false;
97-
_fixture.ConfigureHandler = (handler) =>
98-
{
99-
Assert.Equal(DecompressionMethods.None, handler.AutomaticDecompression);
100-
configureHandlerInvoked = true;
101-
};
102-
var sut = _fixture.GetSut();
103-
104-
_ = sut.Create(_fixture.HttpOptions);
105-
106-
Assert.True(configureHandlerInvoked);
107-
}
108-
109-
[Fact]
110-
public void Create_DecompressionMethodDefault_AllBitsSet()
111-
{
112-
var configureHandlerInvoked = false;
113-
_fixture.ConfigureHandler = (handler) =>
114-
{
115-
Assert.Equal(~DecompressionMethods.None, handler.AutomaticDecompression);
116-
configureHandlerInvoked = true;
117-
};
118-
var sut = _fixture.GetSut();
119-
120-
_ = sut.Create(_fixture.HttpOptions);
121-
122-
Assert.True(configureHandlerInvoked);
123-
}
124-
12588
[Fact]
12689
public void Create_DefaultHeaders_AcceptJson()
12790
{
12891
var configureHandlerInvoked = false;
129-
_fixture.ConfigureClient = (client) =>
92+
_fixture.HttpOptions.ConfigureClient = (client) =>
13093
{
13194
Assert.Equal("application/json", client.DefaultRequestHeaders.Accept.ToString());
13295
configureHandlerInvoked = true;
@@ -138,23 +101,6 @@ public void Create_DefaultHeaders_AcceptJson()
138101
Assert.True(configureHandlerInvoked);
139102
}
140103

141-
[Fact]
142-
public void Create_HttpProxyOnOptions_HandlerUsesProxy()
143-
{
144-
_fixture.HttpOptions.HttpProxy = new WebProxy("https://proxy.sentry.io:31337");
145-
var configureHandlerInvoked = false;
146-
_fixture.ConfigureHandler = (handler) =>
147-
{
148-
Assert.Same(_fixture.HttpOptions.HttpProxy, handler.Proxy);
149-
configureHandlerInvoked = true;
150-
};
151-
var sut = _fixture.GetSut();
152-
153-
_ = sut.Create(_fixture.HttpOptions);
154-
155-
Assert.True(configureHandlerInvoked);
156-
}
157-
158104
[Fact]
159105
public void Create_ProvidedCreateHttpClientHandler_ReturnedHandlerUsed()
160106
{

0 commit comments

Comments
 (0)