// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using EpicGames.Core;
using EpicGames.Horde.Telemetry.Metrics;
using EpicGames.Serialization;
#pragma warning disable CA2227
namespace EpicGames.Horde.Telemetry
{
///
/// Generic message for a telemetry event
///
public class PostTelemetryEventStreamRequest
{
///
/// List of telemetry events
///
public List Events { get; set; } = new List();
}
///
/// Indicates the type of telemetry data being uploaded
///
public enum TelemetryUploadType
{
///
/// A batch of objects.
///
EtEventStream
}
///
/// Metrics meta data for query
///
public class GetTelemetryMetricsMetaResponse
{
///
/// The corresponding metric id
///
public string MetricId { get; set; } = String.Empty;
///
/// Metric grouping information
///
public string GroupBy { get; set; } = String.Empty;
///
/// Metrics groups matching the search terms
///
public List Groups { get; set; } = new List();
///
/// TopN aggregation
///
public int TopN { get; set; } = 0;
///
/// BottomN aggregation
///
public int BottomN { get; set; } = 0;
}
///
/// Metrics matching a particular query
///
public class GetTelemetryMetricsResponse
{
///
/// The corresponding metric id
///
public string MetricId { get; set; } = String.Empty;
///
/// Metric grouping information
///
public string GroupBy { get; set; } = String.Empty;
///
/// Metrics matching the search terms
///
public List Metrics { get; set; } = new List();
}
///
/// Information about a particular metric
///
public class GetTelemetryMetricResponse
{
///
/// Start time for the sample
///
public DateTime Time { get; set; }
///
/// Name of the group
///
public string? Group { get; set; }
///
/// Value for the metric
///
public double Value { get; set; }
}
///
/// The units used to present the telemetry
///
public enum TelemetryMetricUnitType
{
///
/// Time duration
///
Time,
///
/// Ratio 0-100%
///
Ratio,
///
/// Artbitrary numeric value
///
Value
}
///
/// The type of
///
public enum TelemetryMetricGraphType
{
///
/// A line graph
///
Line,
///
/// Key performance indicator (KPI) chart with thrasholds
///
Indicator
}
///
/// Metric attached to a telemetry chart
///
public class TelemetryChartMetricConfig
{
///
/// Associated metric id
///
[Required]
public MetricId Id { get; set; }
///
/// The threshold for KPI values
///
public int? Threshold { get; set; }
///
/// The metric alias for display purposes
///
public string? Alias { get; set; }
}
///
/// Telemetry chart configuraton
///
public class TelemetryChartConfig
{
///
/// The name of the chart, will be displayed on the dashboard
///
[Required]
public string Name { get; set; } = null!;
///
/// The unit to display
///
public TelemetryMetricUnitType Display { get; set; } = TelemetryMetricUnitType.Time;
///
/// The graph type
///
public TelemetryMetricGraphType Graph { get; set; } = TelemetryMetricGraphType.Line;
///
/// List of configured metrics
///
public List Metrics { get; set; } = new List();
///
/// The min unit value for clamping chart
///
public int? Min { get; set; }
///
/// The max unit value for clamping chart
///
public int? Max { get; set; }
}
///
/// A chart categody, will be displayed on the dashbord under an associated pivot
///
public class TelemetryCategoryConfig
{
///
/// The name of the category
///
[Required]
public string Name { get; set; } = null!;
///
/// The charts contained within the category
///
public List Charts { get; set; } = new List { };
}
///
/// A telemetry view variable used for filtering the charting data
///
public class TelemetryVariableConfig
{
///
/// The name of the variable for display purposes
///
[Required]
public string Name { get; set; } = null!;
///
/// The associated data group attached to the variable
///
[Required]
public string Group { get; set; } = null!;
///
/// The default values to select
///
public List Defaults { get; set; } = new List { };
}
///
/// A telemetry view of related metrics, divided into categofies
///
public class TelemetryViewConfig
{
///
/// Identifier for the view
///
[Required]
public TelmetryViewId Id { get; set; }
///
/// The name of the view
///
[Required]
public string Name { get; set; } = null!;
///
/// The telemetry store this view uses
///
[Required]
public TelemetryStoreId TelemetryStoreId { get; set; }
///
/// The variables used to filter the view data
///
public List Variables { get; set; } = new List { };
///
/// The categories contained within the view
///
public List Categories { get; set; } = new List { };
}
///
/// Identifier for a particular metric view
///
/// Id to construct from
[LogValueType]
[JsonSchemaString]
[TypeConverter(typeof(StringIdTypeConverter))]
[StringIdConverter(typeof(TelmetryViewIdConverter))]
[CbConverter(typeof(StringIdCbConverter))]
public record struct TelmetryViewId(StringId Id)
{
///
/// Constructor
///
public TelmetryViewId(string id) : this(new StringId(id))
{
}
///
public bool IsEmpty => Id.IsEmpty;
///
public override string ToString() => Id.ToString();
}
///
/// Converter to and from instances.
///
class TelmetryViewIdConverter : StringIdConverter
{
///
public override TelmetryViewId FromStringId(StringId id) => new TelmetryViewId(id);
///
public override StringId ToStringId(TelmetryViewId value) => value.Id;
}
///
/// Metric attached to a telemetry chart
///
public class GetTelemetryChartMetricResponse
{
///
/// Associated metric id
///
public string MetricId { get; set; } = null!;
///
/// The threshold for KPI values
///
public int? Threshold { get; set; }
///
/// The metric alias for display purposes
///
public string? Alias { get; set; }
}
///
/// Telemetry chart configuraton
///
public class GetTelemetryChartResponse
{
///
/// The name of the chart, will be displayed on the dashboard
///
public string Name { get; set; } = null!;
///
/// The unit to display
///
public string Display { get; set; } = null!;
///
/// The graph type
///
public string Graph { get; set; } = null!;
///
/// List of configured metrics
///
public List Metrics { get; set; } = new List();
///
/// The min unit value for clamping chart
///
public int? Min { get; set; }
///
/// The max unit value for clamping chart
///
public int? Max { get; set; }
}
///
/// A chart categody, will be displayed on the dashbord under an associated pivot
///
public class GetTelemetryCategoryResponse
{
///
/// The name of the category
///
public string Name { get; set; } = null!;
///
/// The charts contained within the category
///
public List Charts { get; set; } = new List { };
}
///
/// A telemetry view variable used for filtering the charting data
///
public class GetTelemetryVariableResponse
{
///
/// The name of the variable for display purposes
///
public string Name { get; set; } = null!;
///
/// The associated data group attached to the variable
///
public string Group { get; set; } = null!;
///
/// The default values to select
///
public List Defaults { get; set; } = new List { };
}
///
/// A telemetry view of related metrics, divided into categofies
///
public class GetTelemetryViewResponse
{
///
/// Identifier for the view
///
public string Id { get; set; } = null!;
///
/// The name of the view
///
public string Name { get; set; } = null!;
///
/// The telemetry store the view uses
///
public string TelemetryStoreId { get; set; } = null!;
///
/// The variables used to filter the view data
///
public List Variables { get; set; } = new List { };
///
/// The categories contained within the view
///
public List Categories { get; set; } = new List { };
}
}