Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TracePropagationTarget #2763

Merged
merged 5 commits into from Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions CHANGELOG.md
Expand Up @@ -45,17 +45,17 @@ API Changes:
```
SentrySdk.WithScope(scope =>
{
// Configure your scope here
scope.SetTag("key", "value");
SentrySdk.CaptureEvent(new SentryEvent()); // Capture the event with the configured scope
// Configure your scope here
scope.SetTag("key", "value");
SentrySdk.CaptureEvent(new SentryEvent()); // Capture the event with the configured scope
});
```
##### After
```
SentrySdk.CaptureEvent(new SentryEvent(), scope =>
{
// Configure your scope here
scope.SetTag("key", "value");
// Configure your scope here
scope.SetTag("key", "value");
});
```
- `ISpan` and `ITransaction` have been renamed to `ISpanTracer` and `ITransactionTracer`. You will need to update any references to these interfaces in your code to use the new interface names ([#2731](https://github.com/getsentry/sentry-dotnet/pull/2731))
Expand All @@ -66,6 +66,7 @@ API Changes:
- Reflection cannot be leveraged for JSON Serialization and you may need to supply a `JsonSerializationContext` for types that you'd like to send to Sentry (e.g. in the Span.Context). You can use `SentryOptions.AddJsonSerializerContext` to supply your own context when initializing Sentry.
- When compiling AOT, Sentry isn't able to automatically register an unhandled exception handler in WinUI applications, since that also relies on reflection. If you're using Sentry with a WinUI application and you want to use AOT compilation, you'll need to take care of registering the unhandled event handler yourself. TODO *** Fill in the gaps here when https://github.com/getsentry/sentry-dotnet/issues/2778 has been completed ***
- ([#2732](https://github.com/getsentry/sentry-dotnet/pull/2732))
- The TracePropagationTarget class has been removed. Use the SubstringOrRegexPattern class instead. ([#2763](https://github.com/getsentry/sentry-dotnet/pull/2763))

## Unreleased

Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/SentryOptions.cs
Expand Up @@ -818,11 +818,11 @@ public IList<SubstringOrRegexPattern> FailedRequestTargets
public Func<TransactionSamplingContext, double?>? TracesSampler { get; set; }

// The default propagation list will match anything, but adding to the list should clear that.
private IList<TracePropagationTarget> _tracePropagationTargets = new AutoClearingList<TracePropagationTarget>
(new[] { new TracePropagationTarget(".*") }, clearOnNextAdd: true);
private IList<SubstringOrRegexPattern> _tracePropagationTargets = new AutoClearingList<SubstringOrRegexPattern>
(new[] { new SubstringOrRegexPattern(".*") }, clearOnNextAdd: true);

/// <summary>
/// A customizable list of <see cref="TracePropagationTarget"/> objects, each containing either a
/// A customizable list of <see cref="SubstringOrRegexPattern"/> objects, each containing either a
/// substring or regular expression pattern that can be used to control which outgoing HTTP requests
/// will have the <c>sentry-trace</c> and <c>baggage</c> headers propagated, for purposes of distributed tracing.
/// The default value contains a single value of <c>.*</c>, which matches everything.
Expand All @@ -832,7 +832,7 @@ public IList<SubstringOrRegexPattern> FailedRequestTargets
/// <remarks>
/// Adding an item to the default list will clear the <c>.*</c> value automatically.
/// </remarks>
public IList<TracePropagationTarget> TracePropagationTargets
public IList<SubstringOrRegexPattern> TracePropagationTargets
{
// NOTE: During configuration binding, .NET 6 and lower used to just call Add on the existing item.
// .NET 7 changed this to call the setter with an array that already starts with the old value.
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/SubstringOrRegexPattern.cs
Expand Up @@ -144,5 +144,5 @@ internal class SubstringOrRegexPatternTypeConverter : TypeConverter
sourceType == typeof(string);

public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) =>
new TracePropagationTarget((string)value);
new SubstringOrRegexPattern((string)value);
}
60 changes: 0 additions & 60 deletions src/Sentry/TracePropagationTarget.cs

This file was deleted.

8 changes: 1 addition & 7 deletions test/Sentry.Tests/ApiApprovalTests.Run.Core3_1.verified.txt
Expand Up @@ -677,7 +677,7 @@ namespace Sentry
public System.TimeSpan ShutdownTimeout { get; set; }
public Sentry.StackTraceMode StackTraceMode { get; set; }
public System.Collections.Generic.ICollection<Sentry.SubstringOrRegexPattern> TagFilters { get; set; }
public System.Collections.Generic.IList<Sentry.TracePropagationTarget> TracePropagationTargets { get; set; }
public System.Collections.Generic.IList<Sentry.SubstringOrRegexPattern> TracePropagationTargets { get; set; }
public double? TracesSampleRate { get; set; }
public System.Func<Sentry.TransactionSamplingContext, double?>? TracesSampler { get; set; }
public Sentry.Extensibility.ITransport? Transport { get; set; }
Expand Down Expand Up @@ -1018,12 +1018,6 @@ namespace Sentry
public override string ToString() { }
public static Sentry.SubstringOrRegexPattern op_Implicit(string substringOrRegexPattern) { }
}
[System.ComponentModel.TypeConverter(typeof(Sentry.TracePropagationTargetTypeConverter))]
public class TracePropagationTarget : Sentry.SubstringOrRegexPattern
{
public TracePropagationTarget(System.Text.RegularExpressions.Regex regex) { }
public TracePropagationTarget(string substringOrRegexPattern, System.StringComparison comparison = 5) { }
}
public class Transaction : Sentry.IEventLike, Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.ITransactionContext, Sentry.ITransactionData, Sentry.Protocol.ITraceContext
{
public Transaction(Sentry.ITransactionTracer tracer) { }
Expand Down
Expand Up @@ -678,7 +678,7 @@ namespace Sentry
public System.TimeSpan ShutdownTimeout { get; set; }
public Sentry.StackTraceMode StackTraceMode { get; set; }
public System.Collections.Generic.ICollection<Sentry.SubstringOrRegexPattern> TagFilters { get; set; }
public System.Collections.Generic.IList<Sentry.TracePropagationTarget> TracePropagationTargets { get; set; }
public System.Collections.Generic.IList<Sentry.SubstringOrRegexPattern> TracePropagationTargets { get; set; }
public double? TracesSampleRate { get; set; }
public System.Func<Sentry.TransactionSamplingContext, double?>? TracesSampler { get; set; }
public Sentry.Extensibility.ITransport? Transport { get; set; }
Expand Down Expand Up @@ -1019,12 +1019,6 @@ namespace Sentry
public override string ToString() { }
public static Sentry.SubstringOrRegexPattern op_Implicit(string substringOrRegexPattern) { }
}
[System.ComponentModel.TypeConverter(typeof(Sentry.TracePropagationTargetTypeConverter))]
public class TracePropagationTarget : Sentry.SubstringOrRegexPattern
{
public TracePropagationTarget(System.Text.RegularExpressions.Regex regex) { }
public TracePropagationTarget(string substringOrRegexPattern, System.StringComparison comparison = 5) { }
}
public class Transaction : Sentry.IEventLike, Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.ITransactionContext, Sentry.ITransactionData, Sentry.Protocol.ITraceContext
{
public Transaction(Sentry.ITransactionTracer tracer) { }
Expand Down
Expand Up @@ -678,7 +678,7 @@ namespace Sentry
public System.TimeSpan ShutdownTimeout { get; set; }
public Sentry.StackTraceMode StackTraceMode { get; set; }
public System.Collections.Generic.ICollection<Sentry.SubstringOrRegexPattern> TagFilters { get; set; }
public System.Collections.Generic.IList<Sentry.TracePropagationTarget> TracePropagationTargets { get; set; }
public System.Collections.Generic.IList<Sentry.SubstringOrRegexPattern> TracePropagationTargets { get; set; }
public double? TracesSampleRate { get; set; }
public System.Func<Sentry.TransactionSamplingContext, double?>? TracesSampler { get; set; }
public Sentry.Extensibility.ITransport? Transport { get; set; }
Expand Down Expand Up @@ -1019,12 +1019,6 @@ namespace Sentry
public override string ToString() { }
public static Sentry.SubstringOrRegexPattern op_Implicit(string substringOrRegexPattern) { }
}
[System.ComponentModel.TypeConverter(typeof(Sentry.TracePropagationTargetTypeConverter))]
public class TracePropagationTarget : Sentry.SubstringOrRegexPattern
{
public TracePropagationTarget(System.Text.RegularExpressions.Regex regex) { }
public TracePropagationTarget(string substringOrRegexPattern, System.StringComparison comparison = 5) { }
}
public class Transaction : Sentry.IEventLike, Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.ITransactionContext, Sentry.ITransactionData, Sentry.Protocol.ITraceContext
{
public Transaction(Sentry.ITransactionTracer tracer) { }
Expand Down
8 changes: 1 addition & 7 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Expand Up @@ -676,7 +676,7 @@ namespace Sentry
public System.TimeSpan ShutdownTimeout { get; set; }
public Sentry.StackTraceMode StackTraceMode { get; set; }
public System.Collections.Generic.ICollection<Sentry.SubstringOrRegexPattern> TagFilters { get; set; }
public System.Collections.Generic.IList<Sentry.TracePropagationTarget> TracePropagationTargets { get; set; }
public System.Collections.Generic.IList<Sentry.SubstringOrRegexPattern> TracePropagationTargets { get; set; }
public double? TracesSampleRate { get; set; }
public System.Func<Sentry.TransactionSamplingContext, double?>? TracesSampler { get; set; }
public Sentry.Extensibility.ITransport? Transport { get; set; }
Expand Down Expand Up @@ -1017,12 +1017,6 @@ namespace Sentry
public override string ToString() { }
public static Sentry.SubstringOrRegexPattern op_Implicit(string substringOrRegexPattern) { }
}
[System.ComponentModel.TypeConverter(typeof(Sentry.TracePropagationTargetTypeConverter))]
public class TracePropagationTarget : Sentry.SubstringOrRegexPattern
{
public TracePropagationTarget(System.Text.RegularExpressions.Regex regex) { }
public TracePropagationTarget(string substringOrRegexPattern, System.StringComparison comparison = 5) { }
}
public class Transaction : Sentry.IEventLike, Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.ITransactionContext, Sentry.ITransactionData, Sentry.Protocol.ITraceContext
{
public Transaction(Sentry.ITransactionTracer tracer) { }
Expand Down
8 changes: 4 additions & 4 deletions test/Sentry.Tests/SentryHttpMessageHandlerTests.cs
Expand Up @@ -41,7 +41,7 @@ public async Task SendAsync_SentryTraceHeaderNotSet_SetsHeader_WhenUrlMatchesPro
var failedRequestHandler = Substitute.For<ISentryFailedRequestHandler>();
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("localhost")
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public async Task SendAsync_SentryTraceHeaderNotSet_DoesntSetHeader_WhenUrlDoesn
var failedRequestHandler = Substitute.For<ISentryFailedRequestHandler>();
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("foo")
}
Expand Down Expand Up @@ -323,7 +323,7 @@ public void Send_SentryTraceHeaderNotSet_SetsHeader_WhenUrlMatchesPropagationOpt
var failedRequestHandler = Substitute.For<ISentryFailedRequestHandler>();
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("localhost")
}
Expand Down Expand Up @@ -355,7 +355,7 @@ public void Send_SentryTraceHeaderNotSet_DoesntSetHeader_WhenUrlDoesntMatchesPro
var failedRequestHandler = Substitute.For<ISentryFailedRequestHandler>();
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("foo")
}
Expand Down
18 changes: 9 additions & 9 deletions test/Sentry.Tests/TracePropagationTargetTests.cs
Expand Up @@ -14,8 +14,8 @@ public void SentryOptions_TracePropagationTargets_DefaultAll()
public void SentryOptions_TracePropagationTargets_AddRemovesDefault()
{
var options = new SentryOptions();
options.TracePropagationTargets.Add(new TracePropagationTarget("foo"));
options.TracePropagationTargets.Add(new TracePropagationTarget("bar"));
options.TracePropagationTargets.Add(new SubstringOrRegexPattern("foo"));
options.TracePropagationTargets.Add(new SubstringOrRegexPattern("bar"));

Assert.Equal(2, options.TracePropagationTargets.Count);
Assert.Equal("foo", options.TracePropagationTargets[0].ToString());
Expand All @@ -28,9 +28,9 @@ public void SentryOptions_TracePropagationTargets_SetRemovesDefault()
var options = new SentryOptions();
var targets = new []
{
new TracePropagationTarget(".*"),
new TracePropagationTarget("foo"),
new TracePropagationTarget("bar")
new SubstringOrRegexPattern(".*"),
new SubstringOrRegexPattern("foo"),
new SubstringOrRegexPattern("bar")
};

options.TracePropagationTargets = targets;
Expand Down Expand Up @@ -59,7 +59,7 @@ public void SentryOptions_TracePropagationTargets_EmptyPropagatesNone()
{
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>()
TracePropagationTargets = new List<SubstringOrRegexPattern>()
};

var result1 = options.TracePropagationTargets.ContainsMatch("foo");
Expand All @@ -76,7 +76,7 @@ public void SentryOptions_TracePropagationTargets_OneMatchPropagates()
{
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("foo"),
new("localhost"),
Expand All @@ -93,7 +93,7 @@ public void SentryOptions_TracePropagationTargets_MultipleMatchesPropagates()
{
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("foo"),
new("localhost"),
Expand All @@ -110,7 +110,7 @@ public void SentryOptions_TracePropagationTargets_NoMatchesDoesntPropagates()
{
var options = new SentryOptions
{
TracePropagationTargets = new List<TracePropagationTarget>
TracePropagationTargets = new List<SubstringOrRegexPattern>
{
new("foo"),
new("localhost"),
Expand Down