MCPcopy Create free account
hub / github.com/DoNewsCode/core / WithTracing

Function WithTracing

cron/options.go:77–92  ·  view source on GitHub ↗

WithTracing returns a new Universal job that will trace.

(tracer opentracing.Tracer)

Source from the content-addressed store, hash-verified

75
76// WithTracing returns a new Universal job that will trace.
77func WithTracing(tracer opentracing.Tracer) JobOption {
78 return func(descriptor *JobDescriptor) {
79 innerRun := descriptor.Run
80 descriptor.Run = func(ctx context.Context) error {
81 span, ctx := opentracing.StartSpanFromContextWithTracer(ctx, tracer, fmt.Sprintf("Job: %s", descriptor.Name))
82 defer span.Finish()
83 span.SetTag("schedule", descriptor.RawSpec)
84 err := innerRun(ctx)
85 if err != nil {
86 ext.LogError(span, err)
87 return err
88 }
89 return nil
90 }
91 }
92}
93
94// SkipIfOverlap returns a new JobDescriptor that will skip the job if it overlaps with another job.
95func SkipIfOverlap() JobOption {

Callers 1

TestJobOptionFunction · 0.85

Calls 1

SprintfMethod · 0.65

Tested by 1

TestJobOptionFunction · 0.68