Skip to content

Commit e2833f5

Browse files
authored
Merge pull request #118 from bugsnag/next
Release v1.4.1
2 parents 0c768d2 + bfa51d8 commit e2833f5

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Security.Cryptography;
45
using BugsnagNetworking;
@@ -16,9 +17,18 @@ internal class SpanFactory
1617

1718
private OnSpanEnd _onSpanEnd;
1819

20+
private const string CONNECTION_TYPE_UNAVAILABLE = "unavailable";
21+
private const string CONNECTION_TYPE_CELL = "cell";
22+
private const string CONNECTION_TYPE_WIFI = "wifi";
23+
24+
private string _currentConnectionType = CONNECTION_TYPE_UNAVAILABLE;
25+
26+
private WaitForSeconds _connectionPollRate = new WaitForSeconds(1);
27+
1928
public SpanFactory(OnSpanEnd onSpanEnd)
2029
{
2130
_onSpanEnd = onSpanEnd;
31+
MainThreadDispatchBehaviour.Instance().StartCoroutine(GetConnectionType());
2232
}
2333

2434
private string GetNewTraceId()
@@ -89,7 +99,7 @@ private Span CreateSpan(string name, SpanKind kind, SpanOptions spanOptions)
8999
{
90100
AddToContextStack(newSpan);
91101
}
92-
newSpan.SetAttribute("net.host.connection.type", GetConnectionType());
102+
newSpan.SetAttribute("net.host.connection.type",_currentConnectionType);
93103
return newSpan;
94104
}
95105

@@ -128,18 +138,24 @@ internal Span CreateManualNetworkSpan(string url, HttpVerb httpVerb, SpanOptions
128138
return span;
129139
}
130140

131-
private string GetConnectionType()
141+
private IEnumerator GetConnectionType()
132142
{
133-
switch (Application.internetReachability)
143+
while(true)
134144
{
135-
case NetworkReachability.NotReachable:
136-
return "unavailable";
137-
case NetworkReachability.ReachableViaCarrierDataNetwork:
138-
return "cell";
139-
case NetworkReachability.ReachableViaLocalAreaNetwork:
140-
return "wifi";
141-
default:
142-
return string.Empty;
145+
switch (Application.internetReachability)
146+
{
147+
case NetworkReachability.NotReachable:
148+
_currentConnectionType = CONNECTION_TYPE_UNAVAILABLE;
149+
break;
150+
case NetworkReachability.ReachableViaCarrierDataNetwork:
151+
_currentConnectionType = CONNECTION_TYPE_CELL;
152+
break;
153+
case NetworkReachability.ReachableViaLocalAreaNetwork:
154+
_currentConnectionType = CONNECTION_TYPE_WIFI;
155+
break;
156+
157+
}
158+
yield return _connectionPollRate;
143159
}
144160
}
145161

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Internal/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
internal static class Version
44
{
55
//TODO set this using sed or something in the release automation task
6-
public const string VersionString = "1.4.0";
6+
public const string VersionString = "1.4.1";
77
}
88
}

CHANGELOG.md

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

3+
## v1.4.1 (2024-11-06)
4+
5+
### Bug Fixes
6+
7+
- Fixed issue where creating a span in a background thread caused an exception (mono or IL2CPP Dev builds only) [#117](https://github.com/bugsnag/bugsnag-unity-performance/pull/117)
8+
39
## v1.4.0 (2024-30-05)
410

511
### Additions

0 commit comments

Comments
 (0)