Skip to content

Commit 2aca61a

Browse files
authored
allow setting first class (#107)
1 parent 7c58eb6 commit 2aca61a

File tree

6 files changed

+91
-2
lines changed

6 files changed

+91
-2
lines changed

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Internal/SpanFactory.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ private string ByteArrayToHex(byte[] barray)
5151

5252
internal Span StartCustomSpan(string name, SpanOptions spanOptions)
5353
{
54-
// custom spans are always first class
55-
spanOptions.IsFirstClass = true;
54+
if (spanOptions.IsFirstClass == null)
55+
{
56+
spanOptions.IsFirstClass = true;
57+
}
5658
var span = CreateSpan(name, SpanKind.SPAN_KIND_INTERNAL, spanOptions);
5759
span.SetAttribute("bugsnag.span.category", "custom");
5860
return span;

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## TBD
4+
5+
### Bug Fixes
6+
7+
- Fixed issue where custom spans with the SpanOption IsFirstClass set to false still had it reported as true. [#107](https://github.com/bugsnag/bugsnag-unity-performance/pull/107)
8+
9+
310
## v1.3.3 (2024-03-07)
411

512
### Bug Fixes

features/fixtures/mazerunner/Assets/Scenes/MainScene.unity

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ RectTransform:
151151
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
152152
m_LocalPosition: {x: 0, y: 0, z: 0}
153153
m_LocalScale: {x: 1, y: 1, z: 1}
154+
m_ConstrainProportionsScale: 0
154155
m_Children: []
155156
m_Father: {fileID: 1513513353}
156157
m_RootOrder: 0
@@ -284,6 +285,7 @@ Transform:
284285
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
285286
m_LocalPosition: {x: 0, y: 0, z: 0}
286287
m_LocalScale: {x: 1, y: 1, z: 1}
288+
m_ConstrainProportionsScale: 0
287289
m_Children: []
288290
m_Father: {fileID: 1294582014}
289291
m_RootOrder: 0
@@ -331,6 +333,7 @@ Transform:
331333
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
332334
m_LocalPosition: {x: 0, y: 0, z: 0}
333335
m_LocalScale: {x: 1, y: 1, z: 1}
336+
m_ConstrainProportionsScale: 0
334337
m_Children: []
335338
m_Father: {fileID: 1294582014}
336339
m_RootOrder: 2
@@ -425,6 +428,7 @@ MonoBehaviour:
425428
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
426429
m_Name:
427430
m_EditorClassIdentifier:
431+
m_SendPointerHoverToParent: 1
428432
m_HorizontalAxis: Horizontal
429433
m_VerticalAxis: Vertical
430434
m_SubmitButton: Submit
@@ -457,6 +461,7 @@ Transform:
457461
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
458462
m_LocalPosition: {x: 0, y: 0, z: 0}
459463
m_LocalScale: {x: 1, y: 1, z: 1}
464+
m_ConstrainProportionsScale: 0
460465
m_Children: []
461466
m_Father: {fileID: 0}
462467
m_RootOrder: 3
@@ -540,6 +545,7 @@ Transform:
540545
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
541546
m_LocalPosition: {x: 0, y: 0, z: -10}
542547
m_LocalScale: {x: 1, y: 1, z: 1}
548+
m_ConstrainProportionsScale: 0
543549
m_Children: []
544550
m_Father: {fileID: 0}
545551
m_RootOrder: 0
@@ -574,6 +580,7 @@ Transform:
574580
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
575581
m_LocalPosition: {x: 0, y: 0, z: 0}
576582
m_LocalScale: {x: 1, y: 1, z: 1}
583+
m_ConstrainProportionsScale: 0
577584
m_Children: []
578585
m_Father: {fileID: 1294582014}
579586
m_RootOrder: 5
@@ -654,6 +661,7 @@ Transform:
654661
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
655662
m_LocalPosition: {x: 0, y: 0, z: 0}
656663
m_LocalScale: {x: 1, y: 1, z: 1}
664+
m_ConstrainProportionsScale: 0
657665
m_Children: []
658666
m_Father: {fileID: 1294582014}
659667
m_RootOrder: 7
@@ -709,6 +717,7 @@ Transform:
709717
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
710718
m_LocalPosition: {x: 0, y: 0, z: 0}
711719
m_LocalScale: {x: 1, y: 1, z: 1}
720+
m_ConstrainProportionsScale: 0
712721
m_Children: []
713722
m_Father: {fileID: 1294582014}
714723
m_RootOrder: 3
@@ -751,6 +760,7 @@ Transform:
751760
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
752761
m_LocalPosition: {x: 0, y: 0, z: 0}
753762
m_LocalScale: {x: 1, y: 1, z: 1}
763+
m_ConstrainProportionsScale: 0
754764
m_Children:
755765
- {fileID: 259057445}
756766
- {fileID: 1452957866}
@@ -798,6 +808,7 @@ Transform:
798808
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
799809
m_LocalPosition: {x: 0, y: 0, z: 0}
800810
m_LocalScale: {x: 1, y: 1, z: 1}
811+
m_ConstrainProportionsScale: 0
801812
m_Children: []
802813
m_Father: {fileID: 1294582014}
803814
m_RootOrder: 1
@@ -974,6 +985,7 @@ Canvas:
974985
m_OverrideSorting: 0
975986
m_OverridePixelPerfect: 0
976987
m_SortingBucketNormalizedSize: 0
988+
m_VertexColorAlwaysGammaSpace: 0
977989
m_AdditionalShaderChannelsFlag: 25
978990
m_SortingLayerID: 0
979991
m_SortingOrder: 0
@@ -988,6 +1000,7 @@ RectTransform:
9881000
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
9891001
m_LocalPosition: {x: 0, y: 0, z: 0}
9901002
m_LocalScale: {x: 0, y: 0, z: 0}
1003+
m_ConstrainProportionsScale: 0
9911004
m_Children:
9921005
- {fileID: 41935981}
9931006
m_Father: {fileID: 0}
@@ -1011,6 +1024,7 @@ GameObject:
10111024
- component: {fileID: 1609554507}
10121025
- component: {fileID: 1609554508}
10131026
- component: {fileID: 1609554509}
1027+
- component: {fileID: 1609554510}
10141028
m_Layer: 0
10151029
m_Name: NestedSpans
10161030
m_TagString: Untagged
@@ -1028,6 +1042,7 @@ Transform:
10281042
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
10291043
m_LocalPosition: {x: 0, y: 0, z: 0}
10301044
m_LocalScale: {x: 1, y: 1, z: 1}
1045+
m_ConstrainProportionsScale: 0
10311046
m_Children: []
10321047
m_Father: {fileID: 1294582014}
10331048
m_RootOrder: 6
@@ -1080,6 +1095,18 @@ MonoBehaviour:
10801095
m_Script: {fileID: 11500000, guid: 7dd649800dec840e9976f9e905c3c236, type: 3}
10811096
m_Name:
10821097
m_EditorClassIdentifier:
1098+
--- !u!114 &1609554510
1099+
MonoBehaviour:
1100+
m_ObjectHideFlags: 0
1101+
m_CorrespondingSourceObject: {fileID: 0}
1102+
m_PrefabInstance: {fileID: 0}
1103+
m_PrefabAsset: {fileID: 0}
1104+
m_GameObject: {fileID: 1609554504}
1105+
m_Enabled: 1
1106+
m_EditorHideFlags: 0
1107+
m_Script: {fileID: 11500000, guid: 8b054c11fc1404cd6ad894798aa074cd, type: 3}
1108+
m_Name:
1109+
m_EditorClassIdentifier:
10831110
--- !u!1 &2053587485
10841111
GameObject:
10851112
m_ObjectHideFlags: 0
@@ -1109,6 +1136,7 @@ Transform:
11091136
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
11101137
m_LocalPosition: {x: 0, y: 0, z: 0}
11111138
m_LocalScale: {x: 1, y: 1, z: 1}
1139+
m_ConstrainProportionsScale: 0
11121140
m_Children: []
11131141
m_Father: {fileID: 1294582014}
11141142
m_RootOrder: 8
@@ -1191,6 +1219,7 @@ Transform:
11911219
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
11921220
m_LocalPosition: {x: 0, y: 0, z: 0}
11931221
m_LocalScale: {x: 1, y: 1, z: 1}
1222+
m_ConstrainProportionsScale: 0
11941223
m_Children:
11951224
- {fileID: 1294582014}
11961225
m_Father: {fileID: 0}
@@ -1241,6 +1270,7 @@ Transform:
12411270
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
12421271
m_LocalPosition: {x: 0, y: 0, z: 0}
12431272
m_LocalScale: {x: 1, y: 1, z: 1}
1273+
m_ConstrainProportionsScale: 0
12441274
m_Children: []
12451275
m_Father: {fileID: 1294582014}
12461276
m_RootOrder: 4
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using BugsnagUnityPerformance;
4+
using System.Threading;
5+
using UnityEngine;
6+
7+
public class IsFirstClass : Scenario
8+
{
9+
public override void PrepareConfig(string apiKey, string host)
10+
{
11+
base.PrepareConfig(apiKey, host);
12+
SetMaxBatchSize(3);
13+
}
14+
15+
public override void Run()
16+
{
17+
BugsnagPerformance.StartSpan("FirstClass not set").End();
18+
BugsnagPerformance.StartSpan("FirstClass true", new SpanOptions { IsFirstClass = true }).End();
19+
BugsnagPerformance.StartSpan("FirstClass false", new SpanOptions { IsFirstClass = false }).End();
20+
}
21+
}

features/fixtures/mazerunner/Assets/Scripts/Scenarios/NestedSpans/IsFirstClass.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/nested_spans.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,22 @@ Feature: Nested Spans
6767
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.parentSpanId" is null
6868
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.parentSpanId" is null
6969

70+
Scenario: IsFirstClass
71+
When I run the game in the "IsFirstClass" state
72+
And I wait for 2 spans
73+
Then the trace Bugsnag-Integrity header is valid
74+
And the trace "Bugsnag-Api-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa"
75+
* the trace "Bugsnag-Sent-At" header matches the regex "^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ$"
76+
* the trace "Bugsnag-Span-Sampling" header equals "1:3"
77+
78+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" equals "FirstClass not set"
79+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" bool attribute "bugsnag.span.first_class" is true
80+
81+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.name" equals "FirstClass true"
82+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" bool attribute "bugsnag.span.first_class" is true
83+
84+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.2.name" equals "FirstClass false"
85+
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.2" bool attribute "bugsnag.span.first_class" is false
86+
87+
7088

0 commit comments

Comments
 (0)