getsentry / sentry-unity

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

Metrics not being attached to Spans #1718

Open Fwang36 opened 2 months ago

Fwang36 commented 2 months ago

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which version of the SDK?

2.1.0+8492ce278d15cf71ccaafc6a2f13cdee70cd869b

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

Git-URL

Which version of Unity?

2022.3.36f1

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

editor

Steps to Reproduce

  1. Create custom transaction on scope
  2. Emit a metric within the custom transaction
  3. Open the transaction in Discover and see that it is missing an Emitted Metrics section.

I saw that the current unity sdk uses dotnet 4.7.0, so I tried the same transaction in the dotnet 4.7.0 and it works as expected there.

The Metrics themselves do seem to send, but only if I move the SentrySdk.Metrics.Increment() outside of the transaction, where it does get sent but without any Span Samples

Expected Result

The transaction should contain that section, and the spans should be associated with the Metric

Actual Result

Spans are not associated with Metrics

Any logs or screenshots

This is the transaction I used for both dotnet and unity.

                var transaction = SentrySdk.StartTransaction(
                    "UnityCustomScopeTransaction",
                    "testScopeOperation"
                );
                SentrySdk.ConfigureScope(scope => scope.Transaction = transaction);

                SentrySdk.Metrics.Increment("ButtonClicked",
                tags: new Dictionary<string, string> { { "region", "us-west-1" } }
                );

                transaction.Finish();

Transaction in Unity sdk without Emitted Metrics section -

Screenshot 2024-07-09 at 10 27 00 AM

Transaction in dotnet sdk with the Emitted Metrics section -

Screenshot 2024-07-09 at 10 28 29 AM
bitsandfoxes commented 2 months ago

That is really odd. The Unity SDK does not have any custom handling of metrics and uses the .NET SDK as-is. We'll have to investigate. Thanks for letting us know!

Fwang36 commented 4 weeks ago

hey @bitsandfoxes,

Have you had a chance to take a look at this? A user has written in asking for an update.

bitsandfoxes commented 4 weeks ago

Since it's not entirely clear how metrics are going to be sent in the near-ish future we've put this on the backlog until we know what we're building before going in and fixing it. Sorry to have not any more helpful updates.