Skip to content

Commit 612823d

Browse files
stephanosclaude
andauthored
Log outbound queue circuit breaker state changes (#11661)
### What changed Sets gobreaker's OnStateChange hook on the outbound queue circuit breaker pool, logging every transition. ### Why Obtain more details for debugging curcuit breaker in production. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ba91985 commit 612823d

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

chasm/lib/callback/invocable_outbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (n invocableOutbound) Invoke(
4646
traceLogger := log.With(h.logger,
4747
tag.WorkflowNamespace(ns.Name().String()),
4848
tag.Operation("CompleteNexusOperation"),
49-
tag.String("destination", taskAttr.Destination),
49+
tag.Destination(taskAttr.Destination),
5050
tag.WorkflowID(n.workflowID),
5151
tag.WorkflowRunID(n.runID),
5252
tag.AttemptStart(time.Now().UTC()),

common/log/tag/tags.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ func Endpoint(endpoint string) ZapTag {
989989
return NewStringTag("endpoint", endpoint)
990990
}
991991

992+
// Destination returns a tag for an outbound task's destination.
993+
func Destination(destination string) ZapTag {
994+
return NewStringTag("destination", destination)
995+
}
996+
992997
func BuildId(buildId string) ZapTag {
993998
return NewStringTag("build-id", buildId)
994999
}

components/callbacks/nexus_invocation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (n nexusInvocation) Invoke(ctx context.Context, ns *namespace.Namespace, e
4747
traceLogger := log.With(e.Logger,
4848
tag.WorkflowNamespace(ns.Name().String()),
4949
tag.Operation("CompleteNexusOperation"),
50-
tag.String("destination", task.destination),
50+
tag.Destination(task.destination),
5151
tag.WorkflowID(n.workflowID),
5252
tag.WorkflowRunID(n.runID),
5353
tag.AttemptStart(time.Now().UTC()),

service/history/circuitbreakerpool/fx.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package circuitbreakerpool
33
import (
44
"fmt"
55

6+
"github.com/sony/gobreaker"
67
"go.temporal.io/server/common/circuitbreaker"
8+
"go.temporal.io/server/common/log"
9+
"go.temporal.io/server/common/log/tag"
710
"go.temporal.io/server/common/namespace"
811
"go.temporal.io/server/service/history/configs"
912
"go.temporal.io/server/service/history/tasks"
@@ -21,6 +24,7 @@ type OutboundQueueCircuitBreakerPool struct {
2124
func OutboundQueueCircuitBreakerPoolProvider(
2225
namespaceRegistry namespace.Registry,
2326
config *configs.Config,
27+
logger log.SnTaggedLogger,
2428
) *OutboundQueueCircuitBreakerPool {
2529
return &OutboundQueueCircuitBreakerPool{
2630
CircuitBreakerPool: NewCircuitBreakerPool(
@@ -37,6 +41,7 @@ func OutboundQueueCircuitBreakerPoolProvider(
3741
key.NamespaceID,
3842
key.Destination,
3943
),
44+
OnStateChange: onStateChange(key, nsName.String(), logger),
4045
})
4146
initial, cancel := config.OutboundQueueCircuitBreakerSettings(
4247
nsName.String(),
@@ -50,3 +55,22 @@ func OutboundQueueCircuitBreakerPoolProvider(
5055
),
5156
}
5257
}
58+
59+
// onStateChange logs breaker transitions.
60+
func onStateChange(
61+
key tasks.TaskGroupNamespaceIDAndDestination,
62+
nsName string,
63+
logger log.SnTaggedLogger,
64+
) func(name string, from gobreaker.State, to gobreaker.State) {
65+
return func(_ string, from gobreaker.State, to gobreaker.State) {
66+
logger.Warn(
67+
"outbound queue circuit breaker state change",
68+
tag.WorkflowNamespace(nsName),
69+
tag.WorkflowNamespaceID(key.NamespaceID),
70+
tag.Destination(key.Destination),
71+
tag.NewStringTag("task-group", key.TaskGroup),
72+
tag.NewStringTag("from-state", from.String()),
73+
tag.NewStringTag("to-state", to.String()),
74+
)
75+
}
76+
}

0 commit comments

Comments
 (0)