Add .env option to disable runtime WF stacktrace
This commit is contained in:
@@ -1223,6 +1223,12 @@
|
||||
# Default: <no value>
|
||||
# WORKFLOW_CALL_STACK_SIZE=<no value>
|
||||
|
||||
###############################################################################
|
||||
# Enables execution stack trace construction
|
||||
# Type: bool
|
||||
# Default: <no value>
|
||||
# WORKFLOW_STACK_TRACE_ENABLED=<no value>
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# Discovery
|
||||
|
||||
@@ -21,6 +21,11 @@ workflow: schema.#optionsGroup & {
|
||||
defaultGoExpr: "16"
|
||||
description: "Defines the maximum call stack size between workflows"
|
||||
}
|
||||
stack_trace_enabled: {
|
||||
type: "bool"
|
||||
defaultGoExpr: "true"
|
||||
description: "Enables execution stack trace construction"
|
||||
}
|
||||
}
|
||||
title: "Workflow"
|
||||
}
|
||||
|
||||
@@ -285,6 +285,9 @@ func (svc *session) spawn(g *wfexec.Graph, workflowID uint64, trace bool, callSt
|
||||
|
||||
// blocks until session is set
|
||||
ses = types.NewSession(<-s.session)
|
||||
if !svc.opt.StackTraceEnabled {
|
||||
ses.DisableStacktrace()
|
||||
}
|
||||
|
||||
svc.mux.Lock()
|
||||
svc.pool[ses.ID] = ses
|
||||
|
||||
@@ -15,6 +15,10 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
runtimeOptions struct {
|
||||
disableStacktrace bool
|
||||
}
|
||||
|
||||
// Instance of single workflow execution
|
||||
Session struct {
|
||||
ID uint64 `json:"sessionID,string"`
|
||||
@@ -43,6 +47,8 @@ type (
|
||||
|
||||
session *wfexec.Session
|
||||
|
||||
runtimeOpts runtimeOptions `json:"-"`
|
||||
|
||||
// For keeping runtime stacktrace,
|
||||
// even if we do not want to store it on every update
|
||||
//
|
||||
@@ -112,6 +118,10 @@ func NewSession(s *wfexec.Session) *Session {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) DisableStacktrace() {
|
||||
s.runtimeOpts.disableStacktrace = true
|
||||
}
|
||||
|
||||
func (s *Session) Exec(ctx context.Context, step wfexec.Step, input *expr.Vars) error {
|
||||
return s.session.Exec(ctx, step, input)
|
||||
}
|
||||
@@ -165,10 +175,12 @@ func (s *Session) Apply(ssp SessionStartParams) {
|
||||
}
|
||||
|
||||
func (s *Session) AppendRuntimeStacktrace(frame *wfexec.Frame) {
|
||||
s.l.RLock()
|
||||
defer s.l.RUnlock()
|
||||
if !s.runtimeOpts.disableStacktrace {
|
||||
s.l.RLock()
|
||||
defer s.l.RUnlock()
|
||||
|
||||
s.RuntimeStacktrace = append(s.RuntimeStacktrace, frame)
|
||||
s.RuntimeStacktrace = append(s.RuntimeStacktrace, frame)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) CopyRuntimeStacktrace() {
|
||||
|
||||
Generated
+7
-5
@@ -252,9 +252,10 @@ type (
|
||||
}
|
||||
|
||||
WorkflowOpt struct {
|
||||
Register bool `env:"WORKFLOW_REGISTER"`
|
||||
ExecDebug bool `env:"WORKFLOW_EXEC_DEBUG"`
|
||||
CallStackSize int `env:"WORKFLOW_CALL_STACK_SIZE"`
|
||||
Register bool `env:"WORKFLOW_REGISTER"`
|
||||
ExecDebug bool `env:"WORKFLOW_EXEC_DEBUG"`
|
||||
CallStackSize int `env:"WORKFLOW_CALL_STACK_SIZE"`
|
||||
StackTraceEnabled bool `env:"WORKFLOW_STACK_TRACE_ENABLED"`
|
||||
}
|
||||
|
||||
DiscoveryOpt struct {
|
||||
@@ -1066,8 +1067,9 @@ func Websocket() (o *WebsocketOpt) {
|
||||
// This function is auto-generated
|
||||
func Workflow() (o *WorkflowOpt) {
|
||||
o = &WorkflowOpt{
|
||||
Register: true,
|
||||
CallStackSize: 16,
|
||||
Register: true,
|
||||
CallStackSize: 16,
|
||||
StackTraceEnabled: true,
|
||||
}
|
||||
|
||||
// Custom defaults
|
||||
|
||||
Reference in New Issue
Block a user