Skip to content

Commit

Permalink
Merge branch 'main' into fix/warning-in-global-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Jul 17, 2021
2 parents a2d26c3 + 68dd94d commit 4b58a56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Add IsParentSampled to ITransactionContext ([#1128](https://github.com/getsentry/sentry-dotnet/pull/1128)
- Avoid warn in global mode ([#1132](https://github.com/getsentry/sentry-dotnet/pull/1132))
- Fix `ParentSampledId` being reset on `Transaction` ([#1130](https://github.com/getsentry/sentry-dotnet/pull/1130))

## 3.8.1

Expand Down
7 changes: 5 additions & 2 deletions src/Sentry/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,15 @@ public Transaction(string name, string operation)
/// Initializes an instance of <see cref="Transaction"/>.
/// </summary>
public Transaction(ITransaction tracer)
: this(tracer.Name, tracer.Operation)
: this(tracer.Name)
{
// Contexts have to be set first because other fields use that
Contexts = tracer.Contexts;

ParentSpanId = tracer.ParentSpanId;
SpanId = tracer.SpanId;
TraceId = tracer.TraceId;
Operation = tracer.Operation;
Platform = tracer.Platform;
Release = tracer.Release;
StartTimestamp = tracer.StartTimestamp;
Expand All @@ -214,7 +218,6 @@ public Transaction(ITransaction tracer)
IsSampled = tracer.IsSampled;
Level = tracer.Level;
Request = tracer.Request;
Contexts = tracer.Contexts;
User = tracer.User;
Environment = tracer.Environment;
Sdk = tracer.Sdk;
Expand Down
19 changes: 7 additions & 12 deletions test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public async Task Transaction_is_bound_on_the_scope_automatically()
public async Task Transaction_is_started_automatically_from_incoming_trace_header()
{
// Arrange
ITransactionData transaction = null;

var sentryClient = Substitute.For<ISentryClient>();

var hub = new Internal.Hub(new SentryOptions
Expand All @@ -149,11 +147,7 @@ public async Task Transaction_is_started_automatically_from_incoming_trace_heade
app.UseEndpoints(routes =>
{
routes.Map("/person/{id}", _ =>
{
transaction = hub.GetSpan() as ITransactionData;
return Task.CompletedTask;
});
routes.Map("/person/{id}", _ => Task.CompletedTask);
});
})
);
Expand All @@ -169,11 +163,12 @@ public async Task Transaction_is_started_automatically_from_incoming_trace_heade
await client.SendAsync(request);

// Assert
transaction.Should().NotBeNull();
transaction?.Name.Should().Be("GET /person/{id}");
transaction.TraceId.Should().Be(SentryId.Parse("75302ac48a024bde9a3b3734a82e36c8"));
transaction.ParentSpanId.Should().Be(SpanId.Parse("1000000000000000"));
transaction.IsSampled.Should().BeFalse();
sentryClient.Received(1).CaptureTransaction(Arg.Is<Transaction>(t =>
t.Name == "GET /person/{id}" &&
t.TraceId == SentryId.Parse("75302ac48a024bde9a3b3734a82e36c8") &&
t.ParentSpanId == SpanId.Parse("1000000000000000") &&
t.IsSampled == false
));
}

[Fact]
Expand Down

0 comments on commit 4b58a56

Please sign in to comment.