-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
37 lines (37 loc) · 1 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Package spancheck defines a linter that checks for mistakes with OTEL trace spans.
//
// # Analyzer spancheck
//
// spancheck: check for mistakes with OpenTelemetry trace spans.
//
// Common mistakes with OTEL trace spans include forgetting to call End:
//
// func(ctx context.Context) {
// ctx, span := otel.Tracer("app").Start(ctx, "span")
// // defer span.End() should be here
//
// // do stuff
// }
//
// Forgetting to set an Error status:
//
// ctx, span := otel.Tracer("app").Start(ctx, "span")
// defer span.End()
//
// if err := task(); err != nil {
// // span.SetStatus(codes.Error, err.Error()) should be here
// span.RecordError(err)
// return fmt.Errorf("failed to run task: %w", err)
// }
//
// Forgetting to record the Error:
//
// ctx, span := otel.Tracer("app").Start(ctx, "span")
// defer span.End()
//
// if err := task(); err != nil {
// span.SetStatus(codes.Error, err.Error())
// // span.RecordError(err) should be here
// return fmt.Errorf("failed to run task: %w", err)
// }
package spancheck