-
Notifications
You must be signed in to change notification settings - Fork 4
/
activity.go
70 lines (57 loc) · 1.48 KB
/
activity.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package sentrytemporal
import (
"context"
"errors"
"github.com/getsentry/sentry-go"
"go.temporal.io/sdk/activity"
"go.temporal.io/sdk/interceptor"
)
type activityInboundInterceptor struct {
interceptor.ActivityInboundInterceptorBase
root *workerInterceptor
}
func (a *activityInboundInterceptor) ExecuteActivity(
ctx context.Context,
in *interceptor.ExecuteActivityInput,
) (ret interface{}, err error) {
hub := a.root.hub.Clone()
ctx = sentry.SetHubOnContext(ctx, hub)
configureScope := func(scope *sentry.Scope) {
info := activity.GetInfo(ctx)
scope.SetContext("activity info", mustStruct2Map(info))
scope.SetContext("execute activity input", mustStruct2Map(in))
scope.SetTag("temporal_io_kind", "ExecuteActivity")
scope.SetFingerprint(
[]string{
info.TaskQueue,
info.ActivityType.Name,
"{{ default }}",
},
)
if a.root.options.ActivityScopeCustomizer != nil {
a.root.options.ActivityScopeCustomizer(ctx, scope, err)
}
}
defer func() {
if x := recover(); x != nil {
hub.ConfigureScope(configureScope)
hub.ConfigureScope(func(scope *sentry.Scope) {
scope.SetLevel(sentry.LevelFatal)
})
_ = hub.Recover(x)
panic(x)
}
}()
ret, err = a.Next.ExecuteActivity(ctx, in)
if err != nil {
if errors.Is(err, activity.ErrResultPending) {
return
}
if skipper := a.root.options.ActivityErrorSkipper; skipper != nil && skipper(ctx, err) {
return
}
hub.ConfigureScope(configureScope)
_ = hub.CaptureException(err)
}
return
}