Skip to content
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.
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 @@
- OTel activities that are marked as not recorded are no longer sent to Sentry ([#3890](https://github.com/getsentry/sentry-dotnet/pull/3890))
- Unknown stack frames in profiles on .NET 8+ ([#3942](https://github.com/getsentry/sentry-dotnet/pull/3942))
- Deduplicate profiling stack frames ([#3941](https://github.com/getsentry/sentry-dotnet/pull/3941))
- Ignore null value on CocoaScopeObserver.SetTag ([#3948](https://github.com/getsentry/sentry-dotnet/pull/3948))

## 5.1.0

Expand Down
6 changes: 6 additions & 0 deletions src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void SetExtra(string key, object? value)

public void SetTag(string key, string value)
{
if (value is null)
{
_options.LogDebug("Tag with key '{0}' was null. Use Unset to remove tags instead.", key);
return;
}

try
{
SentryCocoaSdk.ConfigureScope(scope => scope.SetTagValue(value, key));
Expand Down
18 changes: 18 additions & 0 deletions test/Sentry.Tests/ScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,24 @@ public void Filtered_tags_are_not_set()

scope.Tags.Should().OnlyContain(pair => pair.Key == "AzFunctions" && pair.Value == "rule");
}

[Fact]
public void SetTag_NullValue_DoesNotThrowArgumentNullException()
{
var scope = new Scope();

ArgumentNullException exception = null;
try
{
scope.SetTag("IAmNull", null);
}
catch (ArgumentNullException e)
{
exception = e;
}

Assert.Null(exception);
}
}

public static class ScopeTestExtensions
Expand Down
Loading