Skip to content

Commit

Permalink
fix: Do not export empty trace data
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Oct 30, 2024
1 parent 1bcaa05 commit 58b5a9e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions internal/tasks/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,23 @@ func (c *Controller) fetchProjectsCiData(ctx context.Context, projectIds []int64
return projectsCiData{}, err
}

traces, err := c.convertTraceSpans(pipelines, jobs, sections)
traceData, err := c.convertTraceData(pipelines, jobs, sections)
if err := handleError(err, "convert trace spans"); err != nil {
return projectsCiData{}, err
}
var traces []*typespb.Trace
if len(traceData.ResourceSpans) > 0 {
traces = append(traces, &typespb.Trace{
Data: traceData,
})
}

return projectsCiData{
Pipelines: pipelines,
Jobs: jobs,
Sections: sections,
Metrics: metrics,
Traces: []*typespb.Trace{traces},
Traces: traces,
TestReports: testReports,
TestSuites: testSuites,
TestCases: testCases,
Expand Down Expand Up @@ -528,7 +534,7 @@ func (c *Controller) exportProjectsCiData(ctx context.Context, data projectsCiDa
return errs
}

func (c *Controller) convertTraceSpans(pipelines []types.Pipeline, jobs []types.Job, sections []types.Section) (*typespb.Trace, error) {
func (c *Controller) convertTraceData(pipelines []types.Pipeline, jobs []types.Job, sections []types.Section) (*tracepb.TracesData, error) {
var (
pipelineSpans []*tracepb.Span
buildJobSpans []*tracepb.Span
Expand Down Expand Up @@ -600,11 +606,8 @@ func (c *Controller) convertTraceSpans(pipelines []types.Pipeline, jobs []types.
)
}

traceData := &tracepb.TracesData{
return &tracepb.TracesData{
ResourceSpans: resourceSpans,
}
return &typespb.Trace{
Data: traceData,
}, nil
}

Expand Down

0 comments on commit 58b5a9e

Please sign in to comment.