Skip to content

Commit 2aab467

Browse files
committed
feat: pass SentryHint to IScopeObserver
1 parent d95347e commit 2aab467

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- 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))
88
- SpanTracer and TransactionTracer are still public but these are now `sealed` (see also [#4627](https://github.com/getsentry/sentry-dotnet/pull/4627))
99
- 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))
10+
- `IScopeObserver.AddBreadcrumb` now takes a `SentryHint` as a second parameter ([#4694](https://github.com/getsentry/sentry-dotnet/pull/4694))
1011

1112
### Features
1213

src/Sentry/IScopeObserver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface IScopeObserver
88
/// <summary>
99
/// Adds a breadcrumb.
1010
/// </summary>
11-
public void AddBreadcrumb(Breadcrumb breadcrumb);
11+
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint);
1212

1313
/// <summary>
1414
/// Sets an extra.

src/Sentry/Internal/ScopeObserver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public ScopeObserver(
1717
_options = options;
1818
}
1919

20-
public void AddBreadcrumb(Breadcrumb breadcrumb)
20+
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
2121
{
2222
_options.DiagnosticLogger?.Log(SentryLevel.Debug,
2323
"{0} Scope Sync - Adding breadcrumb m:\"{1}\" l:\"{2}\"", null, _name,
2424
breadcrumb.Message, breadcrumb.Level);
25-
AddBreadcrumbImpl(breadcrumb);
25+
AddBreadcrumbImpl(breadcrumb, hint);
2626
}
2727

28-
public abstract void AddBreadcrumbImpl(Breadcrumb breadcrumb);
28+
public abstract void AddBreadcrumbImpl(Breadcrumb breadcrumb, SentryHint hint);
2929

3030
public void SetExtra(string key, object? value)
3131
{

src/Sentry/Platforms/Android/AndroidScopeObserver.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ public AndroidScopeObserver(SentryOptions options)
1818
_innerObserver = observer is AndroidScopeObserver ? null : observer;
1919
}
2020

21-
public void AddBreadcrumb(Breadcrumb breadcrumb)
21+
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
2222
{
2323
try
2424
{
2525
var b = breadcrumb.ToJavaBreadcrumb();
26-
JavaSdk.Sentry.AddBreadcrumb(b);
26+
var h = hint.ToJavaHint();
27+
JavaSdk.Sentry.AddBreadcrumb(b, h);
2728
}
2829
finally
2930
{
30-
_innerObserver?.AddBreadcrumb(breadcrumb);
31+
_innerObserver?.AddBreadcrumb(breadcrumb, hint);
3132
}
3233
}
3334

src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CocoaScopeObserver(SentryOptions options)
1818
_innerObserver = observer is CocoaScopeObserver ? null : observer;
1919
}
2020

21-
public void AddBreadcrumb(Breadcrumb breadcrumb)
21+
public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
2222
{
2323
try
2424
{
@@ -27,7 +27,7 @@ public void AddBreadcrumb(Breadcrumb breadcrumb)
2727
}
2828
finally
2929
{
30-
_innerObserver?.AddBreadcrumb(breadcrumb);
30+
_innerObserver?.AddBreadcrumb(breadcrumb, hint);
3131
}
3232
}
3333

src/Sentry/Platforms/Native/NativeScopeObserver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class NativeScopeObserver : ScopeObserver
1010
{
1111
public NativeScopeObserver(SentryOptions options) : base("Native", options) { }
1212

13-
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
13+
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb, SentryHint hint)
1414
{
1515
// see https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/
1616
var crumb = C.sentry_value_new_breadcrumb(breadcrumb.Type, breadcrumb.Message);

src/Sentry/Scope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public void AddBreadcrumb(Breadcrumb breadcrumb, SentryHint hint)
348348
_breadcrumbs.Enqueue(breadcrumb);
349349
if (Options.EnableScopeSync)
350350
{
351-
Options.ScopeObserver?.AddBreadcrumb(breadcrumb);
351+
Options.ScopeObserver?.AddBreadcrumb(breadcrumb, hint);
352352
}
353353
}
354354

test/Sentry.Tests/ScopeTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,15 @@ public void AddBreadcrumb_ObserverExist_ObserverAddsBreadcrumbIfEnabled(bool obs
686686
EnableScopeSync = observerEnable
687687
});
688688
var breadcrumb = new Breadcrumb(message: "1234");
689+
var hint = new SentryHint(key: "k", value: "v");
689690
var expectedCount = observerEnable ? 2 : 0;
690691

691692
// Act
692-
scope.AddBreadcrumb(breadcrumb);
693-
scope.AddBreadcrumb(breadcrumb);
693+
scope.AddBreadcrumb(breadcrumb, hint);
694+
scope.AddBreadcrumb(breadcrumb, hint);
694695

695696
// Assert
696-
observer.Received(expectedCount).AddBreadcrumb(Arg.Is(breadcrumb));
697+
observer.Received(expectedCount).AddBreadcrumb(Arg.Is(breadcrumb), Arg.Is(hint));
697698
}
698699

699700
[Fact]

0 commit comments

Comments
 (0)