package NStat;

message TStatProto {
    message TResultCount {
        optional uint32 Total = 1;      // sum of all types

        optional uint32 Ok = 2;         // number of successful runs
        optional uint32 No = 3;         // number of skipped/missing/unsuccessful runs
        optional uint32 Errors = 4;     // number of runs failed with exception

        optional uint32 Cached = 5;     // taken from cache (without full run)
    }

    message TRecord {
        optional string Name = 1;         // name of a rule/metarule or initialization step

        // Init stats
        optional double InitTime = 2;     // initialization time (milliseconds)
        optional uint64 Memory  = 3;      // initialization memory (bytes)

        // Runtime stats
        optional TResultCount Counts = 4;       // number of runs, total and separate by result type
        optional double Duration = 5;           // total duration of runs (ms)

        message TQuantile {
            optional uint32 DurationAtLeast = 1;    // a duration step (milliseconds)
            optional TResultCount Counts = 2;       // number of times the run took time
                                                    // equal or more than Duration ms to complete.
        }
        repeated TQuantile Quantile = 9;  // quantiles (usually for 5, 10, 20, 50, 100 ms)
    }

    repeated TRecord Records = 1;
    optional TRecord Total = 2;

    optional double Age = 3;    // period of time during which this stat has been collected (ms)

    optional float Rps = 4; // Requests per second calculated for last 15 minutes

    // Errors groupped by error type
    message TErrorStat {
        optional string Type = 1;
        optional uint32 Count = 2;
    }
    repeated TErrorStat Errors = 5;
}
