Skip to content

Commit 203d62d

Browse files
authored
feat: Bump .NET SDK 6.1.0 and provide experimental Metrics (#2533)
1 parent 8bcaf5a commit 203d62d

10 files changed

Lines changed: 67 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
## Unreleased
44

5-
### Features
6-
7-
- Added content-based error event throttling to prevent repeated errors from consuming quota. The new `IThrottler` interface and `ErrorEventThrottler` implementation deduplicate `LogError`, `LogException`, and `LogAssertion` events based on message + stacktrace fingerprinting. Configurable via the Editor window ("Enable Error Event Throttling" + "Dedupe Window"). Breadcrumbs and structured logs are not affected by default. ([#2479](https://github.com/getsentry/sentry-unity/pull/2479))
8-
95
### Deprecations
106

117
- The time-based log debouncing system (`TimeDebounceBase`, `LogTimeDebounce`, `ErrorTimeDebounce`, `WarningTimeDebounce`) and related options (`EnableLogDebouncing`, `DebounceTimeLog`, `DebounceTimeWarning`, `DebounceTimeError`) are now marked as `[Obsolete]`. Use the new content-based event throttling instead. ([#2479](https://github.com/getsentry/sentry-unity/pull/2479))
@@ -26,12 +22,17 @@
2622
### Features
2723

2824
- Added Nintendo Switch Native Support. The SDK now automatically syncs the scope - tags, breadcrumbs, context - to the native layer, so native crashes have the same rich context as managed events. ([#2503](https://github.com/getsentry/sentry-unity/pull/2503))
25+
- [Sentry trace-connected Metrics](https://docs.sentry.io/product/explore/metrics/) are now available as _experimental_. ([#2533](https://github.com/getsentry/sentry-unity/pull/2533))
26+
- Added content-based error event throttling to prevent repeated errors from consuming quota. The new `IThrottler` interface and `ErrorEventThrottler` implementation deduplicate `LogError`, `LogException`, and `LogAssertion` events based on message + stacktrace fingerprinting. Configurable via the Editor window ("Enable Error Event Throttling" + "Dedupe Window"). Breadcrumbs and structured logs are not affected by default. ([#2479](https://github.com/getsentry/sentry-unity/pull/2479))
2927

3028
### Dependencies
3129

32-
- Bump Java SDK from v8.28.0 to v8.32.0 ([#2462](https://github.com/getsentry/sentry-unity/pull/2462), [#2481](https://github.com/getsentry/sentry-unity/pull/2481), [#2493](https://github.com/getsentry/sentry-unity/pull/2493), [#2530](https://github.com/getsentry/sentry-unity/pull/2530))
33-
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8320)
34-
- [diff](https://github.com/getsentry/sentry-java/compare/8.28.0...8.32.0)
30+
- Bump .NET SDK from v6.0.0 to v6.1.0 ([#2533](https://github.com/getsentry/sentry-unity/pull/2533))
31+
- [changelog](https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md#610)
32+
- [diff](https://github.com/getsentry/sentry-dotnet/compare/6.0.0...6.1.0)
33+
- Bump Java SDK from v8.28.0 to v8.31.0 ([#2462](https://github.com/getsentry/sentry-unity/pull/2462), [#2481](https://github.com/getsentry/sentry-unity/pull/2481), [#2493](https://github.com/getsentry/sentry-unity/pull/2493))
34+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8310)
35+
- [diff](https://github.com/getsentry/sentry-java/compare/8.28.0...8.31.0)
3536
- Bump Native SDK from v0.12.2 to v0.12.6 ([#2471](https://github.com/getsentry/sentry-unity/pull/2471), [#2505](https://github.com/getsentry/sentry-unity/pull/2505), [#2512](https://github.com/getsentry/sentry-unity/pull/2512), [#2524](https://github.com/getsentry/sentry-unity/pull/2524))
3637
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0126)
3738
- [diff](https://github.com/getsentry/sentry-native/compare/0.12.2...0.12.6)

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Deterministic>true</Deterministic>
1010
<Features>strict</Features>
1111
<SignAssembly>false</SignAssembly>
12+
<NoWarn>$(NoWarn);SENTRYTRACECONNECTEDMETRICS</NoWarn>
1213

1314
<!-- This is the default for our lowest supported version 2020 LTS: netstandard2.0 -->
1415
<!-- The TargetFramework gets overridden depending on the UnityVersion here and in test/props -->

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "10.0.100",
4-
"workloadVersion": "10.0.100",
3+
"version": "10.0.102",
4+
"workloadVersion": "10.0.101.1",
55
"rollForward": "disable",
66
"allowPrerelease": false
77
}

samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MonoBehaviour:
1111
m_EditorHideFlags: 0
1212
m_Script: {fileID: -668357930, guid: 43ec428a58422470fa764bdba9d9bc19, type: 3}
1313
m_Name: SentryOptions
14-
m_EditorClassIdentifier:
14+
m_EditorClassIdentifier:
1515
<Enabled>k__BackingField: 1
1616
<Dsn>k__BackingField: https://e9ee299dbf554dfd930bc5f3c90d5d4b@o447951.ingest.us.sentry.io/4504604988538880
1717
<CaptureInEditor>k__BackingField: 1
@@ -27,8 +27,8 @@ MonoBehaviour:
2727
<AutoAwakeTraces>k__BackingField: 0
2828
<AutoSessionTracking>k__BackingField: 1
2929
<AutoSessionTrackingInterval>k__BackingField: 30000
30-
<ReleaseOverride>k__BackingField:
31-
<EnvironmentOverride>k__BackingField:
30+
<ReleaseOverride>k__BackingField:
31+
<EnvironmentOverride>k__BackingField:
3232
<AttachStacktrace>k__BackingField: 1
3333
<AttachScreenshot>k__BackingField: 1
3434
<ScreenshotQuality>k__BackingField: 1
@@ -78,6 +78,7 @@ MonoBehaviour:
7878
<PlayStationNativeSupportEnabled>k__BackingField: 1
7979
<SwitchNativeSupportEnabled>k__BackingField: 1
8080
<Il2CppLineNumberSupportEnabled>k__BackingField: 1
81+
<EnableMetrics>k__BackingField: 1
8182
<OptionsConfiguration>k__BackingField: {fileID: 11400000, guid: cea63afb7c75f429799422326f926abe, type: 2}
8283
<Debug>k__BackingField: 1
8384
<DebugOnlyInEditor>k__BackingField: 0

src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,19 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti
190190
}
191191
}
192192
}
193+
194+
EditorGUILayout.Space();
195+
EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray);
196+
EditorGUILayout.Space();
197+
198+
{
199+
GUILayout.Label("Metrics", EditorStyles.boldLabel);
200+
201+
options.EnableMetrics = EditorGUILayout.Toggle(
202+
new GUIContent("Enable Metrics",
203+
"Whether the SDK sends metrics to Sentry. " +
204+
"Metrics are connected to traces for correlation."),
205+
options.EnableMetrics);
206+
}
193207
}
194208
}

src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void ProcessStructuredLog(string message, LogType logType)
154154

155155
_options.LogDebug("Capturing structured log message of type '{0}'.", logType);
156156

157-
SentryLog.GetTraceIdAndSpanId(_hub, out var traceId, out var spanId);
157+
_hub.GetTraceIdAndSpanId(out var traceId, out var spanId);
158158
SentryLog log = new(_clock.GetUtcNow(), traceId, ToLogLevel(logType), message) { SpanId = spanId };
159159

160160
log.SetDefaultAttributes(_options, UnitySdkInfo.Sdk);

src/Sentry.Unity/ScriptableSentryUnityOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null)
130130
[field: SerializeField] public bool PlayStationNativeSupportEnabled { get; set; } = true;
131131
[field: SerializeField] public bool SwitchNativeSupportEnabled { get; set; } = true;
132132
[field: SerializeField] public bool Il2CppLineNumberSupportEnabled { get; set; } = true;
133+
[field: SerializeField] public bool EnableMetrics { get; set; } = true;
133134
[field: SerializeField] public SentryOptionsConfiguration? OptionsConfiguration { get; set; }
134135

135136
[field: SerializeField] public bool Debug { get; set; } = true;
@@ -227,6 +228,8 @@ internal SentryUnityOptions ToSentryUnityOptions(
227228
AddBreadcrumbsWithStructuredLogs = AddBreadcrumbsWithStructuredLogs
228229
};
229230

231+
options.Experimental.EnableMetrics = EnableMetrics;
232+
230233
// By default, the cacheDirectoryPath gets set on known platforms. We're overwriting this behaviour here.
231234
if (!EnableOfflineCaching)
232235
{

src/Sentry.Unity/SentrySdk.Dotnet.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,34 @@ public static void ResumeSession()
530530
/// </remarks>
531531
[Obsolete("WARNING: This method deliberately causes a crash, and should not be used in a real application.")]
532532
public static void CauseCrash(CrashType crashType) => Sentry.SentrySdk.CauseCrash(crashType);
533+
534+
/// <summary>
535+
/// Sentry features that are currently in an experimental state.
536+
/// </summary>
537+
/// <remarks>
538+
/// Experimental features are subject to binary, source and behavioral breaking changes in future updates.
539+
/// </remarks>
540+
public static ExperimentalSentrySdk Experimental { get; } = new();
541+
542+
/// <summary>
543+
/// Sentry features that are currently in an experimental state.
544+
/// </summary>
545+
/// <remarks>
546+
/// Experimental features are subject to binary, source and behavioral breaking changes in future updates.
547+
/// </remarks>
548+
public sealed class ExperimentalSentrySdk
549+
{
550+
internal ExperimentalSentrySdk()
551+
{
552+
}
553+
554+
/// <summary>
555+
/// Gets the metric emitter for emitting counters, gauges, and distributions connected to traces.
556+
/// </summary>
557+
public SentryMetricEmitter Metrics
558+
{
559+
[DebuggerStepThrough]
560+
get => Sentry.SentrySdk.Experimental.Metrics;
561+
}
562+
}
533563
}

src/sentry-dotnet

Submodule sentry-dotnet updated 135 files

test/Sentry.Unity.Tests/Stubs/TestHub.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Threading.Tasks;
5+
using Sentry.Internal;
56
using Sentry.Protocol.Envelopes;
67

78
namespace Sentry.Unity.Tests.Stubs;
@@ -124,6 +125,8 @@ public void WithScope(Action<Scope> scopeCallback)
124125
public SentryStructuredLogger Logger { get; }
125126
#pragma warning restore SENTRY0001
126127

128+
public SentryMetricEmitter Metrics => DisabledSentryMetricEmitter.Instance;
129+
127130
public ITransactionTracer StartTransaction(ITransactionContext context, IReadOnlyDictionary<string, object?> customSamplingContext) =>
128131
new TransactionTracer(this, context);
129132

0 commit comments

Comments
 (0)