Skip to content

Commit 8706936

Browse files
Merged IHasTransactionNameSource into ITransactionContext (#2654)
1 parent 56e5b06 commit 8706936

File tree

9 files changed

+16
-24
lines changed

9 files changed

+16
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ without native/platform specific bindings and SDKs. See [this ticket for more de
1616

1717
API Changes:
1818

19+
- Removed IHasTransactionNameSource. Use ITransactionContext instead. ([#2654](https://github.com/getsentry/sentry-dotnet/pull/2654))
1920
- Adding `Distribution` to `IEventLike` ([#2660](https://github.com/getsentry/sentry-dotnet/pull/2660))
2021

2122
### Features

src/Sentry/IHasTransactionNameSource.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Sentry/ITransactionContext.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public interface ITransactionContext : ISpanContext
1414
/// Whether the parent transaction of this transaction has been sampled.
1515
/// </summary>
1616
bool? IsParentSampled { get; }
17+
18+
/// <summary>
19+
/// The source of the transaction name.
20+
/// </summary>
21+
TransactionNameSource NameSource { get; }
1722
}

src/Sentry/Internal/NoOpTransaction.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public bool? IsParentSampled
2525
set { }
2626
}
2727

28+
public TransactionNameSource NameSource => TransactionNameSource.Custom;
29+
2830
public string? Distribution
2931
{
3032
get => string.Empty;

src/Sentry/Transaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Sentry;
99
/// <summary>
1010
/// Sentry performance transaction.
1111
/// </summary>
12-
public class Transaction : ITransactionData, IJsonSerializable, IHasTransactionNameSource, IHasMeasurements
12+
public class Transaction : ITransactionData, IJsonSerializable, IHasMeasurements
1313
{
1414
/// <summary>
1515
/// Transaction's event ID.
@@ -233,7 +233,7 @@ public Transaction(string name, string operation, TransactionNameSource nameSour
233233
/// Initializes an instance of <see cref="Transaction"/>.
234234
/// </summary>
235235
public Transaction(ITransaction tracer)
236-
: this(tracer.Name, tracer is IHasTransactionNameSource t ? t.NameSource : TransactionNameSource.Custom)
236+
: this(tracer.Name, tracer.NameSource)
237237
{
238238
// Contexts have to be set first because other fields use that
239239
Contexts = tracer.Contexts;

src/Sentry/TransactionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Sentry;
33
/// <summary>
44
/// Transaction metadata used for sampling.
55
/// </summary>
6-
public class TransactionContext : SpanContext, ITransactionContext, IHasTransactionNameSource
6+
public class TransactionContext : SpanContext, ITransactionContext
77
{
88
/// <inheritdoc />
99
public string Name { get; set; }

src/Sentry/TransactionTracer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Sentry;
77
/// <summary>
88
/// Transaction tracer.
99
/// </summary>
10-
public class TransactionTracer : ITransaction, IHasTransactionNameSource, IHasMeasurements
10+
public class TransactionTracer : ITransaction, IHasMeasurements
1111
{
1212
private readonly IHub _hub;
1313
private readonly SentryOptions? _options;
@@ -43,7 +43,7 @@ public SentryId TraceId
4343
/// <inheritdoc cref="ITransaction.Name" />
4444
public string Name { get; set; }
4545

46-
/// <inheritdoc cref="IHasTransactionNameSource.NameSource" />
46+
/// <inheritdoc cref="ITransactionContext.NameSource" />
4747
public TransactionNameSource NameSource { get; set; }
4848

4949
/// <inheritdoc cref="ITransaction.IsParentSampled" />
@@ -229,7 +229,7 @@ internal TransactionTracer(IHub hub, ITransactionContext context, TimeSpan? idle
229229
_hub = hub;
230230
_options = _hub.GetSentryOptions();
231231
Name = context.Name;
232-
NameSource = context is IHasTransactionNameSource c ? c.NameSource : TransactionNameSource.Custom;
232+
NameSource = context.NameSource;
233233
Operation = context.Operation;
234234
SpanId = context.SpanId;
235235
ParentSpanId = context.ParentSpanId;

test/Sentry.AspNet.Tests/HttpContextExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void StartSentryTransaction_CreatesValidTransaction()
1616
// Assert
1717
transaction.Name.Should().Be("GET /the/path");
1818
transaction.Operation.Should().Be("http.server");
19-
((IHasTransactionNameSource)transaction).NameSource.Should().Be(TransactionNameSource.Url);
19+
transaction.NameSource.Should().Be(TransactionNameSource.Url);
2020
}
2121

2222
[Fact]

test/Sentry.AspNetCore.Tests/SentryTracingMiddlewareTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public async Task Transaction_is_bound_on_the_scope_automatically()
101101
// Assert
102102
transaction.Should().NotBeNull();
103103
transaction.Name.Should().Be("GET /person/{id}");
104-
((IHasTransactionNameSource)transaction).NameSource.Should().Be(TransactionNameSource.Route);
104+
transaction.NameSource.Should().Be(TransactionNameSource.Route);
105105
}
106106

107107
[Fact]

0 commit comments

Comments
 (0)