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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Unreleased

### Fixes
### Features

- The SDK now also reports the currently allocated memory when reporting an event or transaction. ([#2398](https://github.com/getsentry/sentry-unity/pull/2398))

### Fixes

- Fixed an issue where screenshot capture triggered on a burst job would crash the game. The SDK can now also capture screenshots on events that occur outside of the main thread ([#2392](https://github.com/getsentry/sentry-unity/pull/2392))
- Structured logs now have the `origin` and `sdk` attributes correctly set ([#2390](https://github.com/getsentry/sentry-unity/pull/2390))
Expand Down
16 changes: 16 additions & 0 deletions src/Sentry.Unity/UnityEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void SetEventContext(IEventLike sentryEvent)
{
try
{
PopulateApp(sentryEvent.Contexts.App);
PopulateDevice(sentryEvent.Contexts.Device);
// Populating the SDK Integrations here (for now) instead of UnityScopeIntegration because it cannot be guaranteed
// that it got added last or that there was not an integration added at a later point
Expand All @@ -49,6 +50,21 @@ private void SetEventContext(IEventLike sentryEvent)
}
}

private void PopulateApp(App app)
{
if (!MainThreadData.IsMainThread())
{
return;
}

// The Profiler returns '0' if it is not available
var totalAllocatedMemory = UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong();
if (totalAllocatedMemory > 0)
{
app.Memory = totalAllocatedMemory;
}
}

private void PopulateDevice(Device device)
{
if (!MainThreadData.IsMainThread())
Expand Down
2 changes: 1 addition & 1 deletion src/sentry-dotnet
Submodule sentry-dotnet updated 75 files
+2 −2 .generated.NoMobile.sln
+106 −87 CHANGELOG.md
+2 −2 Sentry-CI-Build-Linux-NoMobile.slnf
+2 −2 Sentry-CI-Build-Linux.slnf
+2 −2 Sentry-CI-Build-Windows-arm64.slnf
+2 −2 Sentry-CI-Build-Windows.slnf
+2 −2 Sentry-CI-Build-macOS.slnf
+1 −1 Sentry-CI-CodeQL.slnf
+2 −2 Sentry.sln
+1 −1 SentryMobile.slnf
+2 −2 SentryNoMobile.slnf
+2 −2 SentryNoSamples.slnf
+2 −5 benchmarks/Sentry.Benchmarks/Extensions.Logging/SentryStructuredLoggerBenchmarks.cs
+1 −4 benchmarks/Sentry.Benchmarks/StructuredLogBatchProcessorBenchmarks.cs
+24 −0 integration-test/android.Tests.ps1
+99 −1 integration-test/net9-maui/App.xaml.cs
+2 −35 integration-test/net9-maui/MainPage.xaml.cs
+6 −0 integration-test/net9-maui/MauiProgram.cs
+1 −1 samples/Directory.Build.props
+1 −1 samples/Sentry.Samples.AspNetCore.Basic/Program.cs
+2 −2 samples/Sentry.Samples.Console.Basic/Program.cs
+2 −2 samples/Sentry.Samples.ME.Logging/Program.cs
+1 −1 samples/Sentry.Samples.Maui/MauiProgram.cs
+1 −1 samples/Sentry.Samples.Serilog/Program.cs
+1 −1 scripts/generate-solution-filters-config.yaml
+3 −0 src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj
+3 −0 src/Sentry.Bindings.Android/Transforms/Metadata.xml
+2 −2 src/Sentry.Compiler.Extensions/BuildPropertySourceGenerator.cs
+1 −1 src/Sentry.Compiler.Extensions/GeneratedCodeText.cs
+1 −1 src/Sentry.Compiler.Extensions/OutputKindExtensions.cs
+0 −0 src/Sentry.Compiler.Extensions/Sentry.Compiler.Extensions.csproj
+1 −1 src/Sentry.Extensions.Logging/SentryStructuredLogger.cs
+5 −4 src/Sentry.Serilog/SentrySink.cs
+7 −7 src/Sentry.Serilog/SentrySinkExtensions.cs
+2 −9 src/Sentry/BindableSentryOptions.cs
+2 −2 src/Sentry/IHub.cs
+2 −2 src/Sentry/Internal/DefaultSentryStructuredLogger.cs
+6 −6 src/Sentry/Platforms/Android/AndroidDiagnosticLogger.cs
+2 −0 src/Sentry/Platforms/Android/Sentry.Android.props
+12 −0 src/Sentry/Platforms/Android/SentrySdk.cs
+10 −0 src/Sentry/Protocol/App.cs
+1 −1 src/Sentry/Sentry.csproj
+25 −46 src/Sentry/SentryOptions.cs
+1 −1 src/Sentry/SentryStructuredLogger.cs
+1 −1 src/Sentry/buildTransitive/Sentry.targets
+1 −1 test/Sentry.AspNetCore.Tests/SentryAspNetCoreStructuredLoggerProviderTests.cs
+2 −2 test/Sentry.Compiler.Extensions.Tests/BuildPropertySourceGeneratorTests.RunResult_BadStrings.verified.txt
+2 −2 test/Sentry.Compiler.Extensions.Tests/BuildPropertySourceGeneratorTests.RunResult_Publish_AotTrue.verified.txt
+2 −2 test/Sentry.Compiler.Extensions.Tests/BuildPropertySourceGeneratorTests.RunResult_Success.verified.txt
+1 −1 test/Sentry.Compiler.Extensions.Tests/BuildPropertySourceGeneratorTests.cs
+1 −1 test/Sentry.Compiler.Extensions.Tests/Sentry.Compiler.Extensions.Tests.csproj
+1 −1 test/Sentry.Compiler.Extensions.Tests/VerifySettingsInitializer.cs
+3 −3 test/Sentry.Extensions.Logging.Tests/SentryLoggingOptionsSetupTests.cs
+1 −1 test/Sentry.Extensions.Logging.Tests/SentryStructuredLoggerProviderTests.cs
+1 −1 test/Sentry.Extensions.Logging.Tests/SentryStructuredLoggerTests.cs
+1 −1 test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj
+4 −1 test/Sentry.Maui.Tests/Internal/SentryMauiStructuredLoggerProviderTests.cs
+1 −1 test/Sentry.Serilog.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt
+1 −1 test/Sentry.Serilog.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
+1 −1 test/Sentry.Serilog.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt
+1 −1 test/Sentry.Serilog.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
+2 −2 test/Sentry.Serilog.Tests/AspNetCoreIntegrationTests.cs
+1 −1 test/Sentry.Serilog.Tests/IntegrationTests.verify.cs
+3 −3 test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs
+36 −4 test/Sentry.Serilog.Tests/SentrySinkTests.Structured.cs
+4 −4 test/Sentry.Serilog.Tests/SerilogAspNetSentrySdkTestFixture.cs
+0 −13 test/Sentry.Testing/BindableTests.cs
+3 −6 test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt
+3 −6 test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
+3 −6 test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt
+3 −6 test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
+8 −8 test/Sentry.Tests/HubTests.cs
+4 −0 test/Sentry.Tests/Protocol/Context/AppTests.cs
+4 −4 test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs
+13 −13 test/Sentry.Tests/SentryStructuredLoggerTests.cs
32 changes: 32 additions & 0 deletions test/Sentry.Unity.Tests/UnityEventScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ public void SentrySdkCaptureEvent(bool captureOnUiThread)
Assert.AreEqual(systemInfo.DeviceModel!.Value, @event.Contexts.Device.Model);
Assert.AreEqual(systemInfo.DeviceUniqueIdentifier!.Value, @event.Contexts.Device.DeviceUniqueIdentifier);
Assert.AreEqual(systemInfo.IsDebugBuild!.Value ? "debug" : "release", @event.Contexts.App.BuildType);
if (captureOnUiThread)
{
Assert.IsNotNull(@event.Contexts.App.Memory);
}

@event.Contexts.TryGetValue(Unity.Protocol.Unity.Type, out var unityProtocolObject);
var unityContext = unityProtocolObject as Unity.Protocol.Unity;
Expand Down Expand Up @@ -276,6 +280,34 @@ public void AppProtocol_Assigned()
Assert.IsNotNull(scope.Contexts.App.BuildType);
}

[Test]
public void AppMemory_SetByEventProcessor()
{
// arrange
var unityEventProcessor = new UnityEventProcessor(_sentryOptions);
var sentryEvent = new SentryEvent();

// act
unityEventProcessor.Process(sentryEvent);

// assert
Assert.IsNotNull(sentryEvent.Contexts.App.Memory);
}

[Test]
public void AppMemory_SetByEventProcessorForTransactions()
{
// arrange
var unityEventProcessor = new UnityEventProcessor(_sentryOptions);
var transaction = new SentryTransaction("test-transaction", "test-operation");

// act
unityEventProcessor.Process(transaction);

// assert
Assert.IsNotNull(transaction.Contexts.App.Memory);
}

[Test]
public void AppProtocol_AppNameIsApplicationName()
{
Expand Down
Loading