initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Services.Core.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class Diagnostics : IDiagnostics
|
||||
{
|
||||
internal const int MaxDiagnosticMessageLength = 10000;
|
||||
internal const string DiagnosticMessageTruncateSuffix = "[truncated]";
|
||||
internal DiagnosticsHandler Handler { get; }
|
||||
|
||||
internal IDictionary<string, string> PackageTags { get; }
|
||||
|
||||
public Diagnostics(DiagnosticsHandler handler, IDictionary<string, string> packageTags)
|
||||
{
|
||||
Handler = handler;
|
||||
PackageTags = packageTags;
|
||||
}
|
||||
|
||||
public void SendDiagnostic(string name, string message, IDictionary<string, string> tags = null)
|
||||
{
|
||||
var diagnostic = new Diagnostic
|
||||
{
|
||||
Content = tags is null
|
||||
? new Dictionary<string, string>(PackageTags)
|
||||
: new Dictionary<string, string>(tags)
|
||||
.MergeAllowOverride(PackageTags),
|
||||
};
|
||||
|
||||
diagnostic.Content.Add(TagKeys.DiagnosticName, name);
|
||||
if (message != null && message.Length > MaxDiagnosticMessageLength)
|
||||
{
|
||||
message = $"{message.Substring(0, MaxDiagnosticMessageLength)}{Environment.NewLine}{DiagnosticMessageTruncateSuffix}";
|
||||
}
|
||||
diagnostic.Content.Add(TagKeys.DiagnosticMessage, message);
|
||||
|
||||
|
||||
Handler.Register(diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d82f57a40dd480c4992d1d23dd773765
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Services.Core.Configuration.Internal;
|
||||
using Unity.Services.Core.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class DiagnosticsFactory : IDiagnosticsFactory
|
||||
{
|
||||
readonly IProjectConfiguration m_ProjectConfig;
|
||||
|
||||
public IReadOnlyDictionary<string, string> CommonTags { get; }
|
||||
|
||||
internal DiagnosticsHandler Handler { get; }
|
||||
|
||||
public DiagnosticsFactory(DiagnosticsHandler handler, IProjectConfiguration projectConfig)
|
||||
{
|
||||
Handler = handler;
|
||||
m_ProjectConfig = projectConfig;
|
||||
|
||||
CommonTags = new Dictionary<string, string>(handler.Cache.Payload.CommonTags)
|
||||
.MergeAllowOverride(handler.Cache.Payload.DiagnosticsCommonTags);
|
||||
}
|
||||
|
||||
public IDiagnostics Create(string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new ArgumentNullException(nameof(packageName));
|
||||
|
||||
var packageTags = FactoryUtils.CreatePackageTags(m_ProjectConfig, packageName);
|
||||
var diagnostics = new Diagnostics(Handler, packageTags);
|
||||
|
||||
return diagnostics;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa076e64208b8334a8a147efeebf66fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class DisabledDiagnostics : IDiagnostics
|
||||
{
|
||||
void IDiagnostics.SendDiagnostic(string name, string message, IDictionary<string, string> tags)
|
||||
{
|
||||
// Do nothing since it's disabled.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30648dc766559254d8ef3209219478ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class DisabledDiagnosticsFactory : IDiagnosticsFactory
|
||||
{
|
||||
IReadOnlyDictionary<string, string> IDiagnosticsFactory.CommonTags { get; }
|
||||
= new Dictionary<string, string>();
|
||||
|
||||
IDiagnostics IDiagnosticsFactory.Create(string packageName) => new DisabledDiagnostics();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30e535d05ac7fad4db50b8dfe6751c14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue