add job starttime to legend

This commit is contained in:
Christoph Kluge 2025-05-05 16:41:05 +02:00
parent 1d13d3dccf
commit fd52fdd35b
6 changed files with 80 additions and 9 deletions

View File

@ -172,6 +172,7 @@ type ScopedStats {
type JobStats {
jobId: Int!
startTime: Int!
stats: [NamedStats!]!
}

View File

@ -171,8 +171,9 @@ type ComplexityRoot struct {
}
JobStats struct {
JobID func(childComplexity int) int
Stats func(childComplexity int) int
JobID func(childComplexity int) int
StartTime func(childComplexity int) int
Stats func(childComplexity int) int
}
JobsStatistics struct {
@ -947,6 +948,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.JobStats.JobID(childComplexity), true
case "JobStats.startTime":
if e.complexity.JobStats.StartTime == nil {
break
}
return e.complexity.JobStats.StartTime(childComplexity), true
case "JobStats.stats":
if e.complexity.JobStats.Stats == nil {
break
@ -2281,6 +2289,7 @@ type ScopedStats {
type JobStats {
jobId: Int!
startTime: Int!
stats: [NamedStats!]!
}
@ -7400,6 +7409,50 @@ func (ec *executionContext) fieldContext_JobStats_jobId(_ context.Context, field
return fc, nil
}
func (ec *executionContext) _JobStats_startTime(ctx context.Context, field graphql.CollectedField, obj *model.JobStats) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_JobStats_startTime(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.StartTime, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(int)
fc.Result = res
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_JobStats_startTime(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "JobStats",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _JobStats_stats(ctx context.Context, field graphql.CollectedField, obj *model.JobStats) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_JobStats_stats(ctx, field)
if err != nil {
@ -11197,6 +11250,8 @@ func (ec *executionContext) fieldContext_Query_jobsMetricStats(ctx context.Conte
switch field.Name {
case "jobId":
return ec.fieldContext_JobStats_jobId(ctx, field)
case "startTime":
return ec.fieldContext_JobStats_startTime(ctx, field)
case "stats":
return ec.fieldContext_JobStats_stats(ctx, field)
}
@ -17527,6 +17582,11 @@ func (ec *executionContext) _JobStats(ctx context.Context, sel ast.SelectionSet,
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "startTime":
out.Values[i] = ec._JobStats_startTime(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "stats":
out.Values[i] = ec._JobStats_stats(ctx, field, obj)
if out.Values[i] == graphql.Null {

View File

@ -97,8 +97,9 @@ type JobResultList struct {
}
type JobStats struct {
JobID int `json:"jobId"`
Stats []*NamedStats `json:"stats"`
JobID int `json:"jobId"`
StartTime int `json:"startTime"`
Stats []*NamedStats `json:"stats"`
}
type JobsStatistics struct {

View File

@ -616,8 +616,9 @@ func (r *queryResolver) JobsMetricStats(ctx context.Context, filter []*model.Job
}
res = append(res, &model.JobStats{
JobID: int(job.JobID),
Stats: sres,
JobID: int(job.JobID),
StartTime: int(job.StartTime.Unix()),
Stats: sres,
})
}
return res, err

View File

@ -39,6 +39,7 @@
let filter = [...filterBuffer];
let comparePlotData = {};
let jobIds = [];
let jobStarts = [];
const sorting = { field: "startTime", type: "col", order: "DESC" };
/* GQL */
@ -49,6 +50,7 @@
query ($filter: [JobFilter!]!, $metrics: [String!]!) {
jobsMetricStats(filter: $filter, metrics: $metrics) {
jobId
startTime
stats {
name
data {
@ -72,6 +74,7 @@
$: matchedCompareJobs = $compareData.data != null ? $compareData.data.jobsMetricStats.length : -1;
$: if ($compareData.data != null) {
jobIds = [];
jobStarts = [];
comparePlotData = {}
jobs2uplot($compareData.data.jobsMetricStats, metrics)
}
@ -121,7 +124,9 @@
let plotIndex = 0
jobs.forEach((j) => {
jobIds.push(j.jobId)
jobStarts.push(j.startTime)
for (let s of j.stats) {
// comparePlotData[s.name].data[0].push(j.startTime)
comparePlotData[s.name].data[0].push(plotIndex)
comparePlotData[s.name].data[1].push(s.data.min)
comparePlotData[s.name].data[2].push(s.data.avg)
@ -181,6 +186,7 @@
title={'Compare '+ m}
xlabel="JobIds"
xticks={jobIds}
xtimes={jobStarts}
ylabel={m}
metric={m}
yunit={comparePlotData[m].unit}
@ -188,9 +194,10 @@
/>
{/each}
<hr/><hr/>
{#each $compareData.data.jobsMetricStats as job (job.jobId)}
{#each $compareData.data.jobsMetricStats as job, jindex (job.jobId)}
<Row>
<Col><b><i>{job.jobId}</i></b></Col>
<Col><b>{jindex}: <i>{job.jobId}</i></b></Col>
<Col><i>{new Date(job.startTime * 1000)}</i></Col>
{#each job.stats as stat (stat.name)}
<Col><b>{stat.name}</b></Col>
<Col>Min {stat.data.min}</Col>

View File

@ -24,6 +24,7 @@
export let data;
export let xlabel;
export let xticks;
export let xtimes;
export let ylabel;
export let yunit;
export let title;
@ -120,7 +121,7 @@
{
label: "JobID",
value: (u, ts, sidx, didx) => {
return xticks[didx];
return xticks[didx] + ' (' + new Date(xtimes[didx] * 1000).toLocaleString() + ')';
},
}
];