Namespaces, assemblies, projects and directories, the solution, binaries, images, systemd units, config paths, environment variables, protocol method names, the media type and the raw chunk magic all move to MoShiro/moshiro. Existing data and deployments are not compatible and must be recreated. Also fix the architecture tests after the solution layout change and make the update tests independent of their order.
47 lines
3.2 KiB
C#
47 lines
3.2 KiB
C#
namespace MoShiro.Backend.Analysis;
|
|
|
|
/// <summary>连接建立、长连接、UDP 压测(udp_train)的指标。</summary>
|
|
public static class SessionMetrics
|
|
{
|
|
private static readonly string[] s_conn = ["connect.conn"];
|
|
private static readonly string[] s_hold = ["hold.hold"];
|
|
private static readonly string[] s_train = ["udp_train.pkt"];
|
|
|
|
public static readonly MetricDef ConnectSuccess = new(
|
|
"connect.success", AccKind.Ratio, s_conn, Ops.OutcomeRatio(ConnectOutcome.Ok), "Connect success", "Share of connection attempts that completed.", Better.Higher,
|
|
[new MetricExport("connect.success", Stat.Pct, Unit.Pct, 99, 90)]);
|
|
|
|
public static readonly MetricDef ConnectTcp = Metric.Histogram(
|
|
"connect.tcp_ms", s_conn, Ops.PhaseMs("tcp_us"), "TCP connect time", "Time to establish the TCP connection.", Unit.Ms, [Stat.P95], good: 100, poor: 400);
|
|
|
|
public static readonly MetricDef ConnectTls = Metric.Histogram(
|
|
"connect.tls_ms", s_conn, Ops.PhaseMs("tls_us"), "TLS handshake time", "Time for the TLS handshake after TCP is up.", Unit.Ms, [Stat.P95], good: 200, poor: 800);
|
|
|
|
public static readonly MetricDef FailTimeout = Metric.Counter(
|
|
"connect.fail.timeout", s_conn, Ops.OutcomeCount(ConnectOutcome.Timeout), "Connect timeouts", "Attempts that timed out.", new MetricExport("connect.fail.timeout", Stat.Count, Unit.Count));
|
|
|
|
public static readonly MetricDef FailReset = Metric.Counter(
|
|
"connect.fail.rst", s_conn, Ops.OutcomeCount(ConnectOutcome.Reset), "Connect resets", "Attempts answered with a reset.", new MetricExport("connect.fail.rst", Stat.Count, Unit.Count));
|
|
|
|
public static readonly MetricDef FailTls = Metric.Counter(
|
|
"connect.fail.tls", s_conn, Ops.OutcomeCount(ConnectOutcome.TlsAlert), "TLS failures", "Attempts that ended in a TLS alert.", new MetricExport("connect.fail.tls", Stat.Count, Unit.Count));
|
|
|
|
public static readonly MetricDef HoldResets = Metric.Counter(
|
|
"hold.resets", s_hold, Ops.HoldEvents(HoldEvent.Reset), "Held connection resets", "Times the held connection was reset.", new MetricExport("hold.resets.per_h", Stat.PerHour, Unit.PerHour, 0.5, 4));
|
|
|
|
public static readonly MetricDef HoldLifetime = Metric.Max(
|
|
"hold.lifetime", s_hold, Ops.HoldLifetime, "Longest connection lifetime", "Longest observed lifetime of the held connection (ms).", Unit.Ms, "hold.lifetime_max", Better.Higher);
|
|
|
|
public static readonly MetricDef TrainLoss = Metric.Ratio(
|
|
"train.loss", s_train, Ops.TrainLoss, "Train loss", "Loss of a fixed-rate UDP stream.", good: 1, poor: 10);
|
|
|
|
public static readonly MetricDef TrainJitter = Metric.Histogram(
|
|
"train.jitter", s_train, Ops.TrainJitter, "Train jitter", "One-way delay variation of a fixed-rate UDP stream.", Unit.Ms, [Stat.P95], good: 3, poor: 20);
|
|
|
|
public static readonly MetricDef TrainRate = Metric.Histogram(
|
|
"train.rate", s_train, Ops.TrainRate, "Train rate", "Delivered rate of a fixed-rate UDP stream per second.", Unit.Mbps, [Stat.P50, Stat.Mean], Better.Higher);
|
|
|
|
public static readonly MetricDef SamplesConnect = Metric.Counter(
|
|
"n.connect", s_conn, Ops.RowCount, "connect samples", "Number of connection attempts.", new MetricExport("n.connect", Stat.Count, Unit.Count), Better.None);
|
|
}
|