initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class DisabledMetrics : IMetrics
|
||||
{
|
||||
void IMetrics.SendGaugeMetric(string name, double value, IDictionary<string, string> tags)
|
||||
{
|
||||
// Do nothing since it's disabled.
|
||||
}
|
||||
|
||||
void IMetrics.SendHistogramMetric(string name, double time, IDictionary<string, string> tags)
|
||||
{
|
||||
// Do nothing since it's disabled.
|
||||
}
|
||||
|
||||
void IMetrics.SendSumMetric(string name, double value, IDictionary<string, string> tags)
|
||||
{
|
||||
// Do nothing since it's disabled.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3acf2a208165fee48a9a8604d2ab412a
|
||||
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 DisabledMetricsFactory : IMetricsFactory
|
||||
{
|
||||
IReadOnlyDictionary<string, string> IMetricsFactory.CommonTags { get; }
|
||||
= new Dictionary<string, string>();
|
||||
|
||||
IMetrics IMetricsFactory.Create(string packageName) => new DisabledMetrics();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2bc7ece372a03404394756573e450dd0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,49 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.Services.Core.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Telemetry.Internal
|
||||
{
|
||||
class Metrics : IMetrics
|
||||
{
|
||||
internal MetricsHandler Handler { get; }
|
||||
|
||||
internal IDictionary<string, string> PackageTags { get; }
|
||||
|
||||
public Metrics(MetricsHandler handler, IDictionary<string, string> packageTags)
|
||||
{
|
||||
Handler = handler;
|
||||
PackageTags = packageTags;
|
||||
}
|
||||
|
||||
internal Metric CreateMetric(string name, double value, MetricType type, IDictionary<string, string> tags)
|
||||
{
|
||||
var metric = new Metric
|
||||
{
|
||||
Name = name,
|
||||
Value = value,
|
||||
Type = type,
|
||||
Tags = tags is null ? PackageTags : tags.MergeAllowOverride(PackageTags),
|
||||
};
|
||||
|
||||
return metric;
|
||||
}
|
||||
|
||||
void IMetrics.SendGaugeMetric(string name, double value, IDictionary<string, string> tags)
|
||||
{
|
||||
var metric = CreateMetric(name, value, MetricType.Gauge, tags);
|
||||
Handler.Register(metric);
|
||||
}
|
||||
|
||||
void IMetrics.SendHistogramMetric(string name, double time, IDictionary<string, string> tags)
|
||||
{
|
||||
var metric = CreateMetric(name, time, MetricType.Histogram, tags);
|
||||
Handler.Register(metric);
|
||||
}
|
||||
|
||||
void IMetrics.SendSumMetric(string name, double value, IDictionary<string, string> tags)
|
||||
{
|
||||
var metric = CreateMetric(name, value, MetricType.Sum, tags);
|
||||
Handler.Register(metric);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be5e351f9a40dd54d8fb1ec23b94a1e9
|
||||
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 MetricsFactory : IMetricsFactory
|
||||
{
|
||||
readonly IProjectConfiguration m_ProjectConfig;
|
||||
|
||||
public IReadOnlyDictionary<string, string> CommonTags { get; }
|
||||
|
||||
internal MetricsHandler Handler { get; }
|
||||
|
||||
public MetricsFactory(MetricsHandler handler, IProjectConfiguration projectConfig)
|
||||
{
|
||||
Handler = handler;
|
||||
m_ProjectConfig = projectConfig;
|
||||
|
||||
CommonTags = new Dictionary<string, string>(handler.Cache.Payload.CommonTags)
|
||||
.MergeAllowOverride(handler.Cache.Payload.MetricsCommonTags);
|
||||
}
|
||||
|
||||
public IMetrics Create(string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new ArgumentNullException(nameof(packageName));
|
||||
|
||||
var packageTags = FactoryUtils.CreatePackageTags(m_ProjectConfig, packageName);
|
||||
var metrics = new Metrics(Handler, packageTags);
|
||||
|
||||
return metrics;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0d7f6572d6b64d4f802e930a1670ab5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue