Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
richardelms committed Sep 2, 2024
1 parent ba2cf68 commit 1448934
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ private void DrawSettingsEditorWindow()
EditorGUIUtility.labelWidth = 280;
settings.UseNotifierSettings = EditorGUILayout.Toggle("Use BugSnag Error Monitoring SDK Settings", settings.UseNotifierSettings);
}


if (!NotifierConfigAvaliable() || !settings.UseNotifierSettings)
{
DrawStandaloneSettings(so,settings);
DrawStandaloneSettings(so, settings);
}

if (NotifierConfigAvaliable() && settings.UseNotifierSettings)
Expand All @@ -100,12 +100,12 @@ private void DrawSettingsEditorWindow()
}

EditorGUIUtility.labelWidth = 200;
EditorGUILayout.PropertyField(so.FindProperty("AutoInstrumentAppStart"));
EditorGUILayout.PropertyField(so.FindProperty("Endpoint"));

EditorGUI.indentLevel--;

EditorGUILayout.PropertyField(so.FindProperty("AutoInstrumentAppStart"));
EditorGUILayout.PropertyField(so.FindProperty("ServiceName"));

EditorGUI.indentLevel--;
so.ApplyModifiedProperties();
EditorUtility.SetDirty(settings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public void Configure(PerformanceConfiguration config)
new AttributeModel("device.model.identifier", SystemInfo.deviceModel),
new AttributeModel("service.version", string.IsNullOrEmpty(config.AppVersion) ? Application.version : config.AppVersion),
new AttributeModel("bugsnag.app.platform", GetPlatform()),
new AttributeModel("bugsnag.runtime_versions.unity", Application.unityVersion)

new AttributeModel("bugsnag.runtime_versions.unity", Application.unityVersion),
new AttributeModel("service.name", string.IsNullOrEmpty(config.ServiceName) ? Application.identifier : config.ServiceName)
};
AddNonNullAttribute(GetNativeVersionInfo(config));
AddNonNullAttribute(GetManufacturer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class BugsnagPerformanceSettingsObject : ScriptableObject
public string AppVersion;
public int VersionCode = -1;
public string BundleVersion;
public string ServiceName;

public bool GenerateAnonymousId = true;

Expand Down Expand Up @@ -60,7 +61,9 @@ internal PerformanceConfiguration GetConfig()
config.Endpoint = Endpoint;

config.GenerateAnonymousId = GenerateAnonymousId;


config.ServiceName = ServiceName;

return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ internal List<Func<Span, bool>> GetOnSpanEndCallbacks()

internal bool IsFixedSamplingProbability => SamplingProbability >= 0;

public string ServiceName = string.Empty;

public string GetEndpoint()
{
if(string.IsNullOrEmpty(Endpoint) || Endpoint == LEGACY_DEFAULT_ENDPOINT)
Expand Down
7 changes: 7 additions & 0 deletions features/configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ Feature: Configuration tests
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" equals "VersionCode"
* the trace payload field "resourceSpans.0.resource" string attribute "bugsnag.app.version_code" equals "123"
* the trace payload field "resourceSpans.0.resource" string attribute "bugsnag.device.android_api_version" exists

Scenario: Custom Service Name
When I run the game in the "CustomServiceName" state
And I wait for 1 span
Then the trace Bugsnag-Integrity header is valid
* the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" equals "CustomServiceName"
* the trace payload field "resourceSpans.0.resource" string attribute "service.name" equals "custom.service.name"
15 changes: 15 additions & 0 deletions features/fixtures/mazerunner/Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9cb2c8811d6324400807420081864590, type: 3}
m_Name:
m_EditorClassIdentifier:
ShouldStartNotifier: 0
--- !u!114 &805103374
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -874,6 +875,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8b326621b51b34e96a0c8b53f3e6f3b4, type: 3}
m_Name:
m_EditorClassIdentifier:
ShouldStartNotifier: 0
--- !u!1 &895329258
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1024,6 +1026,7 @@ GameObject:
- component: {fileID: 1452957874}
- component: {fileID: 1452957873}
- component: {fileID: 1452957872}
- component: {fileID: 1452957875}
m_Layer: 0
m_Name: Configuration
m_TagString: Untagged
Expand Down Expand Up @@ -1150,6 +1153,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
ShouldStartNotifier: 0
--- !u!114 &1452957875
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1452957865}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60784bd8dd5b64233afa1f365ad01f71, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1513513349
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using BugsnagUnityPerformance;
using UnityEngine;

public class CustomServiceName : Scenario
{
public override void PreparePerformanceConfig(string apiKey, string host)
{
base.PreparePerformanceConfig(apiKey, host);
SetMaxBatchSize(1);
Configuration.ServiceName = "custom.service.name";
}

public override void Run()
{
var span = BugsnagPerformance.StartSpan("CustomServiceName");
span.End();
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions features/manual_spans.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Feature: Manual creation of spans
* the trace payload field "resourceSpans.0.resource" string attribute "device.id" exists
* the trace payload field "resourceSpans.0.resource" string attribute "device.model.identifier" exists
* the trace payload field "resourceSpans.0.resource" string attribute "service.version" equals "1.0"
* the trace payload field "resourceSpans.0.resource" string attribute "service.name" equals "com.bugsnag.mazerunner"

* the trace payload field "resourceSpans.0.resource" string attribute "bugsnag.app.platform" is one of:
| Android |
| iOS |
Expand Down

0 comments on commit 1448934

Please sign in to comment.