Skip to content

Commit 37fd8c0

Browse files
authored
Merge pull request #71 from bugsnag/next
Release v1.1.0
2 parents ff4f932 + b575376 commit 37fd8c0

File tree

21 files changed

+288
-68
lines changed

21 files changed

+288
-68
lines changed

.buildkite/pipeline.full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ steps:
4545
command:
4646
- "--app=/app/features/fixtures/mazerunner/mazerunner_2020.3.48f1.apk"
4747
- "--farm=bb"
48-
- "--device=ANDROID_11"
48+
- "--device=ANDROID_9|ANDROID_10|ANDROID_11|ANDROID_12|ANDROID_13"
4949
- "--no-tunnel"
5050
- "--aws-public-ip"
5151
concurrency: 25

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ steps:
6060
command:
6161
- "--app=/app/features/fixtures/mazerunner/mazerunner_2021.3.27f1.apk"
6262
- "--farm=bb"
63-
- "--device=ANDROID_11"
63+
- "--device=ANDROID_9|ANDROID_10|ANDROID_11|ANDROID_12|ANDROID_13"
6464
- "--no-tunnel"
6565
- "--aws-public-ip"
6666
concurrency: 25

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Internal/BugsnagPerformanceAutoStart.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ static void OnBeforeSceneLoadRuntimeMethod()
99
var settings = Resources.Load<BugsnagPerformanceSettingsObject>("Bugsnag/BugsnagPerformanceSettingsObject");
1010
if (settings != null)
1111
{
12-
var config = settings.GetConfig();
13-
if (string.IsNullOrEmpty(config.ApiKey))
14-
{
15-
Debug.LogError("BugSnag Performance can't be automatically started as the API key is not set.");
16-
return;
17-
}
12+
var config = settings.GetConfig();
1813
if (settings.StartAutomaticallyAtLaunch)
1914
{
15+
if (string.IsNullOrEmpty(config.ApiKey))
16+
{
17+
Debug.LogError("BugSnag Performance can't be automatically started as the API key is not set.");
18+
return;
19+
}
2020
BugsnagPerformance.Start(config);
2121
}
2222
}

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Internal/Sampler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public bool Sampled(Span span)
4949
if (isSampled)
5050
{
5151
span.UpdateSamplingProbability(p);
52+
span.SetAttribute("bugsnag.sampling.p", p);
5253
}
5354
return isSampled;
5455
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private Span CreateSpan(string name, SpanKind kind, SpanOptions spanOptions)
9191
return newSpan;
9292
}
9393

94-
internal Span CreateAutomaticNetworkSpan(BugsnagUnityWebRequest request)
94+
internal Span CreateAutomaticNetworkSpan(BugsnagUnityWebRequest request,string url)
9595
{
9696
var verb = request.method.ToUpper();
9797

@@ -101,7 +101,7 @@ internal Span CreateAutomaticNetworkSpan(BugsnagUnityWebRequest request)
101101

102102
var span = CreateSpan("HTTP/" + verb, SpanKind.SPAN_KIND_CLIENT, spanOptions);
103103
span.SetAttribute("bugsnag.span.category", "network");
104-
span.SetAttribute("http.url", request.url);
104+
span.SetAttribute("http.url", url);
105105
span.SetAttribute("http.method", verb);
106106
span.SetAttribute("net.host.connection.type", GetConnectionType());
107107
return span;

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.0.0";
6+
public const string VersionString = "1.1.0";
77
}
88
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace BugsnagUnityPerformance
2+
{
3+
public class BugsnagNetworkRequestInfo
4+
{
5+
public string Url;
6+
7+
public BugsnagNetworkRequestInfo(string url)
8+
{
9+
Url = url;
10+
}
11+
}
12+
}

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Public/BugsnagNetworkRequestInfo.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.

BugsnagPerformance/Assets/BugsnagPerformance/Scripts/Public/BugsnagPerformance.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using BugsnagNetworking;
@@ -24,6 +25,7 @@ public class BugsnagPerformance
2425
private AppStartHandler _appStartHandler;
2526
private PersistentState _persistentState;
2627
private PValueUpdater _pValueUpdater;
28+
private Func<BugsnagNetworkRequestInfo, BugsnagNetworkRequestInfo> _networkRequestCallback;
2729

2830
public static void Start(PerformanceConfiguration configuration)
2931
{
@@ -36,12 +38,22 @@ public static void Start(PerformanceConfiguration configuration)
3638
}
3739
IsStarted = true;
3840
}
41+
ValidateApiKey(configuration.ApiKey);
3942
if (ReleaseStageEnabled(configuration))
4043
{
4144
_sharedInstance.Configure(configuration);
4245
_sharedInstance.Start();
4346
}
47+
48+
}
4449

50+
private static void ValidateApiKey(string apiKey)
51+
{
52+
if (!System.Text.RegularExpressions.Regex.IsMatch(apiKey, @"\A\b[0-9a-fA-F]+\b\Z") ||
53+
apiKey.Length != 32)
54+
{
55+
throw new System.Exception($"Invalid Bugsnag Performance configuration. apiKey should be a 32-character hexademical string, got {apiKey} ");
56+
}
4557
}
4658

4759
private static bool ReleaseStageEnabled(PerformanceConfiguration configuration)
@@ -93,6 +105,7 @@ internal class SceneLoadSpanContainer
93105

94106
private void Configure(PerformanceConfiguration config)
95107
{
108+
_networkRequestCallback = config.NetworkRequestCallback;
96109
_cacheManager.Configure(config);
97110
_persistentState.Configure(config);
98111
_delivery.Configure(config);
@@ -116,7 +129,7 @@ private void Start()
116129
_appStartHandler.Start();
117130
SetupNetworkListener();
118131
SetupSceneLoadListeners();
119-
132+
120133
IsStarted = true;
121134
}
122135

@@ -200,13 +213,26 @@ private void SetupNetworkListener()
200213

201214
private void OnRequestSend(BugsnagUnityWebRequest request)
202215
{
203-
var span = _spanFactory.CreateAutomaticNetworkSpan(request);
216+
var url = request.url;
217+
if (_networkRequestCallback != null)
218+
{
219+
var callbackResult = _networkRequestCallback.Invoke(new BugsnagNetworkRequestInfo(url));
220+
if (callbackResult == null || string.IsNullOrEmpty(callbackResult.Url))
221+
{
222+
return;
223+
}
224+
225+
url = callbackResult.Url;
226+
}
227+
var span = _spanFactory.CreateAutomaticNetworkSpan(request, url);
204228
lock (_networkSpansLock)
205229
{
206230
_networkSpans[request] = span;
207231
}
208232
}
209233

234+
235+
210236
private void OnRequestAbort(BugsnagUnityWebRequest request)
211237
{
212238
EndNetworkSpan(request, true);
Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEngine;
1+
using System;
2+
using UnityEngine;
23

34
namespace BugsnagUnityPerformance
45
{
@@ -16,26 +17,7 @@ public class PerformanceConfiguration
1617

1718
//Public config
1819

19-
private string _apiKey;
20-
21-
public string ApiKey
22-
{
23-
get
24-
{
25-
return _apiKey;
26-
}
27-
set
28-
{
29-
if (ValidateApiKey(value))
30-
{
31-
_apiKey = value;
32-
}
33-
else
34-
{
35-
throw new System.Exception($"Invalid Bugsnag Performance configuration. apiKey should be a 32-character hexademical string, got {value} ");
36-
}
37-
}
38-
}
20+
public string ApiKey;
3921

4022
public AutoInstrumentAppStartSetting AutoInstrumentAppStart = AutoInstrumentAppStartSetting.FULL;
4123

@@ -47,17 +29,15 @@ public string ApiKey
4729

4830
public string Endpoint = "https://otlp.bugsnag.com/v1/traces";
4931

32+
public Func<BugsnagNetworkRequestInfo, BugsnagNetworkRequestInfo> NetworkRequestCallback;
33+
5034
public string ReleaseStage = Debug.isDebugBuild ? "development" : "production";
5135

5236
public PerformanceConfiguration(string apiKey)
5337
{
5438
ApiKey = apiKey;
5539
}
5640

57-
private bool ValidateApiKey(string apiKey)
58-
{
59-
return System.Text.RegularExpressions.Regex.IsMatch(apiKey, @"\A\b[0-9a-fA-F]+\b\Z") &&
60-
apiKey.Length == 32;
61-
}
41+
6242
}
6343
}

0 commit comments

Comments
 (0)