getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
200 stars 51 forks source link

Error in 2.10.0 SDK seemingly caused by Metrics Distribution #1703

Open cstavitsky opened 2 weeks ago

cstavitsky commented 2 weeks ago

Opening this issue on behalf of a trialing Sentry customer.

Environment

How do you use Sentry?

Sentry SaaS (sentry.io)

Which version of the SDK?

sentry.dotnet.unity
--
Version | 2.0.1+318ab00a2245007aba0d09b24cbf39dc6daabafd

How did you install the package? (Git-URL, Assetstore)

Git-URL

Which version of Unity?

2021.3.19f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows?

Android/iOS

Steps to Reproduce

(occurs on both Android and iOS devices)

  1. Install 2.10.0 SDK
  2. call Sentry.Sdk.Metrics.Distribution code

Expected Result

Sentry Metrics Distribution would not error.

Actual Result

Received this error:

Exception: MissingMemberException: The lazily-initialized type does not have a public, parameterless constructor.
System.LazyHelper.CreateViaDefaultConstructor (System.Type type) (at <00000000000000000000000000000000>:0)
System.Lazy`1[T].CreateViaDefaultConstructor () (at <00000000000000000000000000000000>:0)
System.Lazy`1[T].ViaConstructor () (at <00000000000000000000000000000000>:0)
System.Lazy`1[T].ExecutionAndPublication (System.LazyHelper executionAndPublication, System.Boolean useDefaultConstructor) (at <00000000000000000000000000000000>:0)
System.Lazy`1[T].CreateValue () (at <00000000000000000000000000000000>:0)
Sentry.MetricAggregator.Emit (Sentry.Protocol.Metrics.MetricType type, System.String key, System.Double value, System.Nullable`1[T] unit, System.Collections.Generic.IDictionary`2[TKey,TValue] tags, System.Nullable`1[T] timestamp, System.Int32 stackLevel) (at <00000000000000000000000000000000>:0)
Sentry.MetricAggregator.Distribution (System.String key, System.Double value, System.Nullable`1[T] unit, System.Collections.Generic.IDictionary`2[TKey,TValue] tags, System.Nullable`1[T] timestamp, System.Int32 stackLevel) (at <00000000000000000000000000000000>:0)
[[[[[[[[[[[[ 2 lines of stacktrace redacted at customer's request ]]]]]]]]]]]]]]]]]]]
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <00000000000000000000000000000000>:0)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () (at <00000000000000000000000000000000>:0)
UniRx.Async.Internal.ReusablePromise.TrySetResult () (at <00000000000000000000000000000000>:0)
UniRx.Async.UniTask+WaitUntilPromise.MoveNext () (at <00000000000000000000000000000000>:0)
UniRx.Async.Internal.PlayerLoopRunner.Run () (at <00000000000000000000000000000000>:0)
--- End of stack trace from previous location where exception was thrown ---
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <00000000000000000000000000000000>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <00000000000000000000000000000000>:0)
Sentry.Unity.Integrations.UnityLogHandlerIntegration:LogException(Exception, Object)
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Customer Notes

The customer noted:

This error occurs on both Android and iOS devices. We removed the code references to Sentry.SentrySdk.Metrics.Distribution, and the error disappeared.

bitsandfoxes commented 2 weeks ago

It gave this a try with the sample that we have but failed to reproduce the issue. I'd really appreciate any hints as to how to reproduce this. Are you seeing this when calling SentrySdk.Metrics.Distribution outside of UniRx?

realkosty commented 5 days ago

@bitsandfoxes Customer reports that

We can call SentrySdk.Metrics.Distribution outside of UniRx with no error

bitsandfoxes commented 1 day ago

Thinking out loud here but maybe it's time we add UniRx to our sample.