Skip to content

Commit a91d8aa

Browse files
committed
cleanup unnecessary span
1 parent b91c849 commit a91d8aa

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

main.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/google/go-github/v39/github"
1313
"github.com/lightstep/otel-launcher-go/launcher"
1414
"go.opentelemetry.io/otel"
15-
"go.opentelemetry.io/otel/codes"
1615
"go.opentelemetry.io/otel/trace"
1716
)
1817

@@ -41,7 +40,9 @@ func getSteps(ctx context.Context, conf actionConfig) error {
4140
}
4241

4342
ctx, workflowSpan := tracer.Start(ctx, *workflow.Name, trace.WithTimestamp(workflow.CreatedAt.Time))
44-
jobs, _, err := client.Actions.ListWorkflowJobs(context.Background(), conf.owner, conf.repo, id, &github.ListWorkflowJobsOptions{})
43+
defer workflowSpan.End(trace.WithTimestamp(workflow.UpdatedAt.Time))
44+
45+
jobs, _, err := client.Actions.ListWorkflowJobs(ctx, conf.owner, conf.repo, id, &github.ListWorkflowJobsOptions{})
4546
if err != nil {
4647
return err
4748
}
@@ -57,7 +58,7 @@ func getSteps(ctx context.Context, conf actionConfig) error {
5758
}
5859
jobSpan.End(trace.WithTimestamp(job.CompletedAt.Time))
5960
}
60-
workflowSpan.End(trace.WithTimestamp(workflow.UpdatedAt.Time))
61+
6162
return nil
6263
}
6364

@@ -102,17 +103,13 @@ func main() {
102103
launcher.WithServiceName(conf.githubRepository),
103104
)
104105
defer lsOtel.Shutdown()
105-
tracer := otel.Tracer(conf.githubRepository)
106-
ctx, span := tracer.Start(context.Background(), conf.workflow)
107-
defer span.End()
108106

109107
if err != nil {
110108
log.Printf("%v", err)
111109
}
112110

113-
err = getSteps(ctx, conf)
111+
err = getSteps(context.Background(), conf)
114112
if err != nil {
115-
span.SetStatus(codes.Error, err.Error())
116113
log.Println(err)
117114
}
118115
}

0 commit comments

Comments
 (0)