Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Spans and Transactions now implement `IDisposable` so that they can be used with `using` statements/declarations that will automatically finish the span with a status of OK when it passes out of scope, if it has not already been finished, to be consistent with `Activity` classes when using OpenTelemetry ([#4627](https://github.com/getsentry/sentry-dotnet/pull/4627))
- SpanTracer and TransactionTracer are still public but these are now `sealed` (see also [#4627](https://github.com/getsentry/sentry-dotnet/pull/4627))
- CaptureFeedback now returns a `SentryId` and a `CaptureFeedbackResult` out parameter that indicate whether feedback was captured successfully and what the reason for failure was otherwise ([#4613](https://github.com/getsentry/sentry-dotnet/pull/4613))
- `IScopeObserver.AddBreadcrumb` now takes a `SentryHint` as a second parameter ([#4694](https://github.com/getsentry/sentry-dotnet/pull/4694))

### Features

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/IScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IScopeObserver
/// <summary>
/// Adds a breadcrumb.
/// </summary>
public void AddBreadcrumb(Breadcrumb breadcrumb);
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint);

/// <summary>
/// Sets an extra.
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/Internal/ScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public ScopeObserver(
_options = options;
}

public void AddBreadcrumb(Breadcrumb breadcrumb)
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: nullability

Do we always have a Hint ... or are Hint optional?
I'm wondering whether this is OK to be non-nullable ... or it could/should be nullable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always have a hint at the call site because the other overload creates an empty hint:

public void AddBreadcrumb(Breadcrumb breadcrumb) => AddBreadcrumb(breadcrumb, new SentryHint());

{
_options.DiagnosticLogger?.Log(SentryLevel.Debug,
"{0} Scope Sync - Adding breadcrumb m:\"{1}\" l:\"{2}\"", null, _name,
breadcrumb.Message, breadcrumb.Level);
AddBreadcrumbImpl(breadcrumb);
AddBreadcrumbImpl(breadcrumb, hint);
}

public abstract void AddBreadcrumbImpl(Breadcrumb breadcrumb);
public abstract void AddBreadcrumbImpl(Breadcrumb breadcrumb, SentryHint hint);

public void SetExtra(string key, object? value)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Sentry/Platforms/Android/AndroidScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ public AndroidScopeObserver(SentryOptions options)
_innerObserver = observer is AndroidScopeObserver ? null : observer;
}

public void AddBreadcrumb(Breadcrumb breadcrumb)
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
{
try
{
var b = breadcrumb.ToJavaBreadcrumb();
JavaSdk.Sentry.AddBreadcrumb(b);
var h = hint.ToJavaHint();
JavaSdk.Sentry.AddBreadcrumb(b, h);
}
finally
{
_innerObserver?.AddBreadcrumb(breadcrumb);
_innerObserver?.AddBreadcrumb(breadcrumb, hint);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CocoaScopeObserver(SentryOptions options)
_innerObserver = observer is CocoaScopeObserver ? null : observer;
}

public void AddBreadcrumb(Breadcrumb breadcrumb)
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
{
try
{
Expand All @@ -27,7 +27,7 @@ public void AddBreadcrumb(Breadcrumb breadcrumb)
}
finally
{
_innerObserver?.AddBreadcrumb(breadcrumb);
_innerObserver?.AddBreadcrumb(breadcrumb, hint);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Platforms/Native/NativeScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class NativeScopeObserver : ScopeObserver
{
public NativeScopeObserver(SentryOptions options) : base("Native", options) { }

public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb, SentryHint hint)
{
// see https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/
var crumb = C.sentry_value_new_breadcrumb(breadcrumb.Type, breadcrumb.Message);
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
_breadcrumbs.Enqueue(breadcrumb);
if (Options.EnableScopeSync)
{
Options.ScopeObserver?.AddBreadcrumb(breadcrumb);
Options.ScopeObserver?.AddBreadcrumb(breadcrumb, hint);
}
}

Expand Down
7 changes: 4 additions & 3 deletions test/Sentry.Tests/ScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,14 +686,15 @@ public void AddBreadcrumb_ObserverExist_ObserverAddsBreadcrumbIfEnabled(bool obs
EnableScopeSync = observerEnable
});
var breadcrumb = new Breadcrumb(message: "1234");
var hint = new SentryHint(key: "k", value: "v");
var expectedCount = observerEnable ? 2 : 0;

// Act
scope.AddBreadcrumb(breadcrumb);
scope.AddBreadcrumb(breadcrumb);
scope.AddBreadcrumb(breadcrumb, hint);
scope.AddBreadcrumb(breadcrumb, hint);

// Assert
observer.Received(expectedCount).AddBreadcrumb(Arg.Is(breadcrumb));
observer.Received(expectedCount).AddBreadcrumb(Arg.Is(breadcrumb), Arg.Is(hint));
}

[Fact]
Expand Down
Loading