Skip to content

Commit

Permalink
Merge branch 'main' into AutoVerify(includeBuildServer-false)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Nov 25, 2021
2 parents 1ef7ac5 + c0c7e39 commit cff0568
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Unreleased

### Features

- Dont log "Ignoring request with Size" when null ([#1348](https://github.com/getsentry/sentry-dotnet/pull/1348))
- Move to stable v6 for `Microsoft.Extensions.*` packages ([#1347](https://github.com/getsentry/sentry-dotnet/pull/1347))

### Fixes

- Update X-Sentry-Auth header to include correct sdk name and version ([#1333](https://github.com/getsentry/sentry-dotnet/pull/1333))

## 3.12.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ public ProtobufRequestExtractionDispatcher(IEnumerable<IProtobufRequestPayloadEx
return null;
}

_options.Log(SentryLevel.Warning,
"Ignoring request with Size {0} and configuration RequestSize {1}", null, request.ContentLength, size);

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0-rc.*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0-rc.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
</ItemGroup>

</Project>
7 changes: 5 additions & 2 deletions src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ public RequestBodyExtractionDispatcher(IEnumerable<IRequestPayloadExtractor> ext
return null;
}

_options.LogWarning("Ignoring request with Size {0} and configuration RequestSize {1}",
request.ContentLength, size);
if (request.ContentLength is not null)
{
_options.LogWarning("Ignoring request with Size {0} and configuration RequestSize {1}",
request.ContentLength, size);
}

return null;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sentry/Internal/Http/HttpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,9 @@ internal HttpRequestMessage CreateRequest(Envelope envelope)
}

var dsn = Dsn.Parse(_options.Dsn);

var authHeader =
$"Sentry sentry_version={_options.SentryVersion}," +
$"sentry_client={_options.ClientVersion}," +
$"sentry_client={SdkVersion.Instance.Name}/{SdkVersion.Instance.Version}," +
$"sentry_key={dsn.PublicKey}," +
(dsn.SecretKey is { } secretKey ? $"sentry_secret={secretKey}," : null) +
$"sentry_timestamp={_clock.GetUtcNow().ToUnixTimeSeconds()}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer) { }
public static Sentry.SentryEvent FromJson(System.Text.Json.JsonElement json) { }
}
public static class SentryEventExtensions { }
public class SentryHttpMessageHandler : System.Net.Http.DelegatingHandler
{
public SentryHttpMessageHandler() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0-rc.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Testing/Sentry.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0-rc.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer) { }
public static Sentry.SentryEvent FromJson(System.Text.Json.JsonElement json) { }
}
public static class SentryEventExtensions { }
public class SentryHttpMessageHandler : System.Net.Http.DelegatingHandler
{
public SentryHttpMessageHandler() { }
Expand Down
20 changes: 20 additions & 0 deletions test/Sentry.Tests/Internals/Http/HttpTransportTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using Sentry.Internal.Http;
using Sentry.Testing;
using Sentry.Tests.Helpers;
Expand Down Expand Up @@ -479,6 +480,25 @@ public void CreateRequest_AuthHeader_IsSet()
authHeader.Should().NotBeNullOrWhiteSpace();
}

[Fact]
public void CreateRequest_AuthHeader_IncludesVersion()
{
// Arrange
var httpTransport = new HttpTransport(
new SentryOptions { Dsn = DsnSamples.ValidDsnWithSecret },
new HttpClient());

var envelope = Envelope.FromEvent(new SentryEvent());

// Act
using var request = httpTransport.CreateRequest(envelope);
var authHeader = request.Headers.GetValues("X-Sentry-Auth").FirstOrDefault();

// Assert
var versionString = Regex.Match(authHeader, @"sentry_client=(\S+),sentry_key").Groups[1].Value;
Assert.Contains(versionString, $"{SdkVersion.Instance.Name}/{SdkVersion.Instance.Version}");
}

[Fact]
public void CreateRequest_RequestMethod_Post()
{
Expand Down

0 comments on commit cff0568

Please sign in to comment.