Skip to content

Commit 8e19573

Browse files
committed
Remove retry on flush failure
1 parent b93eef0 commit 8e19573

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

src/Datadog.Tracer.Tests/ApiTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
2626

2727
public class ApiTests
2828
{
29-
private const int _retries = 2;
30-
3129
[Fact]
3230
public async Task SendServiceAsync_200OK_AllGood()
3331
{
@@ -44,7 +42,7 @@ public async Task SendServiceAsync_200OK_AllGood()
4442
}
4543

4644
[Fact]
47-
public async Task SendServiceAsync_500_Retry()
45+
public async Task SendServiceAsync_500_ErrorIsCaught()
4846
{
4947
var response = new HttpResponseMessage
5048
{
@@ -55,7 +53,8 @@ public async Task SendServiceAsync_500_Retry()
5553

5654
await api.SendServiceAsync(new ServiceInfo());
5755

58-
Assert.Equal(1 + _retries, handler.RequestsCount);
56+
Assert.Equal(1, handler.RequestsCount);
57+
// TODO:bertrand check that it's properly logged
5958
}
6059
}
6160
}

src/Datadog.Tracer/Api.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,15 @@ public Api(Uri baseEndpoint, DelegatingHandler delegatingHandler = null)
5656

5757
private async Task SendAsync<T>(T value, Uri endpoint)
5858
{
59-
const int retries = 2;
60-
for (int i = 0; i < retries + 1; i++)
59+
try
6160
{
62-
try
63-
{
64-
var content = new MsgPackContent<T>(value, _serializationContext);
65-
var response = await _client.PostAsync(endpoint, content);
66-
if(response.StatusCode == HttpStatusCode.OK)
67-
{
68-
return;
69-
}
70-
if((int)response.StatusCode >= 400 && (int)response.StatusCode < 500)
71-
{
72-
// TODO:bertrand log
73-
return;
74-
}
75-
throw new HttpRequestException($"The request to {endpoint} failed with status {response.StatusCode}");
76-
}
77-
catch
78-
{
79-
// TODO:bertrand Log
80-
}
81-
await Task.Delay(TimeSpan.FromSeconds(1));
61+
var content = new MsgPackContent<T>(value, _serializationContext);
62+
var response = await _client.PostAsync(endpoint, content);
63+
response.EnsureSuccessStatusCode();
64+
}
65+
catch
66+
{
67+
// TODO:bertrand log
8268
}
8369
}
8470

0 commit comments

Comments
 (0)