go.temporal.io/server/components/nexusoperations/metrics.go

116 LOC · 48 covered · 68 uncovered · 18 ranges · 54 concepts · 11 introducers · 22 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/components/nexusoperations/completion.go · 283 LOCnexusoperations/completi…go.temporal.io/server/components/nexusoperations/config.go · 225 LOCnexusoperations/config.g…go.temporal.io/server/components/nexusoperations/executors.go · 1250 LOCnexusoperations/executor…executors.go ×1 · 4 introduced LOCexecutors.go ×1sync_failed · 0 introduced LOCsync_failedexecutors.go ×4 · 9 introduced LOCexecutors.go ×4executors.go ×2 · 9 introduced LOCexecutors.go ×2statemachine.go ×3 · 6 introduced LOCstatemachine.go ×3async_start · 0 introduced LOCasync_startexecutors.go ×1 · 2 introduced LOCexecutors.go ×1executors.go ×1 · 7 introduced LOCexecutors.go ×1executors.go ×2 · 2 introduced LOCexecutors.go ×2executors.go ×3 · 10 introduced LOCexecutors.go ×3executors.go ×1 · 3 introduced LOCexecutors.go ×1executors.go ×1 · 7 introduced LOCexecutors.go ×1executors.go ×5 · 17 introduced LOCexecutors.go ×5executors.go ×3 · 6 introduced LOCexecutors.go ×3executors.go ×3 · 9 introduced LOCexecutors.go ×3executors.go ×1 · 1 introduced LOCexecutors.go ×1executors.go ×1 · 5 introduced LOCexecutors.go ×1executors.go ×1 · 3 introduced LOCexecutors.go ×1executors.go ×1 · 3 introduced LOCexecutors.go ×1executors.go ×1 · 4 introduced LOCexecutors.go ×1executors.go ×6 · 35 introduced LOCexecutors.go ×6executors.go ×4 · 21 introduced LOCexecutors.go ×4executors.go ×1 · 1 introduced LOCexecutors.go ×1executors.go ×2 · 3 introduced LOCexecutors.go ×2executors.go ×1 · 4 introduced LOCexecutors.go ×1completion.go ×2 · 12 introduced LOCcompletion.go ×2completion.go ×1 · 2 introduced LOCcompletion.go ×1completion.go ×1 · 1 introduced LOCcompletion.go ×1completion.go ×2 · 4 introduced LOCcompletion.go ×2executors.go ×1 · 2 introduced LOCexecutors.go ×1start-to-close_after_start · 0 introduced LOCstart-to-close_after_sta…completion.go ×18 · 57 introduced LOCcompletion.go ×18TestProcessStartToCloseTimeoutTask · 0 introduced LOCTestProcessStartToCloseT…metrics.go ×2 · 5 introduced LOCmetrics.go ×2executors.go ×1 · 3 introduced LOCexecutors.go ×1schedule-to-close_before_start · 0 introduced LOCschedule-to-close_before…TestProcessTimeoutTask · 0 introduced LOCTestProcessTimeoutTaskexecutors.go ×1 · 3 introduced LOCexecutors.go ×1completion.go ×3 · 17 introduced LOCcompletion.go ×3completion.go ×2 · 13 introduced LOCcompletion.go ×2executors.go ×1 · 3 introduced LOCexecutors.go ×1executors.go ×3 · 6 introduced LOCexecutors.go ×3completion.go ×2 · 19 introduced LOCcompletion.go ×2completion.go ×4 · 15 introduced LOCcompletion.go ×4metrics.go ×1 · 3 introduced LOCmetrics.go ×1executors.go ×3 · 31 introduced LOCexecutors.go ×3metrics.go ×1 · 3 introduced LOCmetrics.go ×1metrics.go ×1 · 3 introduced LOCmetrics.go ×1metrics.go ×1 · 2 introduced LOCmetrics.go ×1metrics.go ×2 · 4 introduced LOCmetrics.go ×2executors.go ×1 · 17 introduced LOCexecutors.go ×1metrics.go ×4 · 11 introduced LOCmetrics.go ×4config.go ×1 · 2 introduced LOCconfig.go ×1metrics.go ×3 · 11 introduced LOCmetrics.go ×3canceled · introduced test · go.temporal.io/server/components/nexusoperations/TestCompletionHandler_EmitsCallerMetrics/canceledcanceledfailed · introduced test · go.temporal.io/server/components/nexusoperations/TestCompletionHandler_EmitsCallerMetrics/failedfailedsucceeded · introduced test · go.temporal.io/server/components/nexusoperations/TestCompletionHandler_EmitsCallerMetrics/succeededsucceededScheduleToCloseTimeout_less_than_MinRequestTimeout · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/ScheduleToCloseTimeout_less_than_MinRequestTimeoutScheduleToCloseTimeout_l…async_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/async_startasync_startcancel_before_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/cancel_before_startcancel_before_startendpoint_not_found · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/endpoint_not_foundendpoint_not_foundendpoint_not_found_on_command_processing · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/endpoint_not_found_on_command_processingendpoint_not_found_on_co…operation_timeout_header_set_by_StartToCloseTimeout · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/operation_timeout_header_set_by_StartToCloseTimeoutoperation_timeout_header…sync_canceled · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/sync_canceledsync_canceledsync_failed · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/sync_failedsync_failedsync_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/sync_startsync_starttoken_to_long · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask/token_to_longtoken_to_longasync_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask_SystemEndpoint/async_startasync_startoperation_error · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask_SystemEndpoint/operation_erroroperation_errorsync_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessInvocationTask_SystemEndpoint/sync_startsync_startTestProcessScheduleToStartTimeoutTask · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessScheduleToStartTimeoutTaskTestProcessScheduleToSta…TestProcessStartToCloseTimeoutTask · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessStartToCloseTimeoutTaskTestProcessStartToCloseT…TestProcessTimeoutTask · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessTimeoutTaskTestProcessTimeoutTaskschedule-to-close_before_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessTimeoutTask_EmitsCallerMetrics/schedule-to-close_before_startschedule-to-close_before…schedule-to-close_before_start_with_service_and_operation_tags · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessTimeoutTask_EmitsCallerMetrics/schedule-to-close_before_start_with_service_and_operation_tagsschedule-to-close_before…start-to-close_after_start · introduced test · go.temporal.io/server/components/nexusoperations/TestProcessTimeoutTask_EmitsCallerMetrics/start-to-close_after_startstart-to-close_after_sta…Focused file · go.temporal.io/server/components/nexusoperations/metrics.go · 116 LOCnexusoperations/metrics.…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package nexusoperations
2
3 import (
4 "strings"
5 "time"
6
7 chasmnexus "go.temporal.io/server/chasm/lib/nexusoperation"
8 nexusoperationpb "go.temporal.io/server/chasm/lib/nexusoperation/gen/nexusoperationpb/v1"
9 "go.temporal.io/server/common/metrics"
10 )
11
12 // metricTagConfig returns the configured metric tag config (nil-safe).
13 > func (e taskExecutor) metricTagConfig() chasmnexus.NexusMetricTagConfig { metrics.go ×1
14 > return e.Config.ResolvedMetricTagConfig()
15 > }
16
17 // operationMetricsHandler returns a metrics handler enriched with caller-side Nexus operation
18 // tags. It mirrors chasm/lib/nexusoperation Operation.metricsHandler so the HSM and CHASM
19 // implementations emit identical metric names and labels (see the HSM->CHASM migration). Unlike
20 // CHASM, HSM Nexus operations are always in-workflow, so workflowType is always the real parent
21 // workflow type (there is no standalone placeholder case).
22 func operationMetricsHandler(
23 base metrics.Handler,
24 tagConfig chasmnexus.NexusMetricTagConfig,
25 op Operation,
26 namespaceName, workflowType string,
27 > ) metrics.Handler { metrics.go ×3
28 > tags := []metrics.Tag{
29 > metrics.NamespaceTag(namespaceName),
30 > metrics.NexusEndpointTag(op.Endpoint),
31 > metrics.WorkflowTypeTag(workflowType),
32 > }
33 > if tagConfig.IncludeServiceTag {
34 > tags = append(tags, metrics.NexusServiceTag(op.Service)) metrics.go ×2
35 > }
36 > if tagConfig.IncludeOperationTag { metrics.go ×3
37 > tags = append(tags, metrics.NexusOperationTag(op.Operation)) metrics.go ×2
38 > }
39 > return base.WithTags(tags...) metrics.go ×3
40 }
41
42 // emitOperationSucceeded emits the success counter and latency metrics for an operation that
43 // completed successfully.
44 > func emitOperationSucceeded(base metrics.Handler, tagConfig chasmnexus.NexusMetricTagConfig, op Operation, namespaceName, workflowType string, closeTime time.Time) { completion.go ×2
45 > emitOperationOutcome(base, tagConfig, op, namespaceName, workflowType, nexusoperationpb.OPERATION_STATUS_SUCCEEDED, closeTime, chasmnexus.NexusOperationSuccessCount.With)
46 > }
47
48 // emitOperationFailed emits the failure counter and latency metrics for an operation that
49 // failed non-retryably.
50 > func emitOperationFailed(base metrics.Handler, tagConfig chasmnexus.NexusMetricTagConfig, op Operation, namespaceName, workflowType string, closeTime time.Time) { metrics.go ×1
51 > emitOperationOutcome(base, tagConfig, op, namespaceName, workflowType, nexusoperationpb.OPERATION_STATUS_FAILED, closeTime, chasmnexus.NexusOperationFailedCount.With)
52 > }
53
54 // emitOperationCanceled emits the cancel counter and latency metrics for an operation that
55 // completed as canceled.
56 > func emitOperationCanceled(base metrics.Handler, tagConfig chasmnexus.NexusMetricTagConfig, op Operation, namespaceName, workflowType string, closeTime time.Time) { completion.go ×3
57 > emitOperationOutcome(base, tagConfig, op, namespaceName, workflowType, nexusoperationpb.OPERATION_STATUS_CANCELED, closeTime, chasmnexus.NexusOperationCancelCount.With)
58 > }
59
60 // emitOperationTimedOut emits the timeout counter (tagged with the timeout type) and latency
61 // metrics for an operation that timed out.
62 > func emitOperationTimedOut(base metrics.Handler, tagConfig chasmnexus.NexusMetricTagConfig, op Operation, namespaceName, workflowType, timeoutType string, closeTime time.Time) { executors.go ×3
63 > emitOperationOutcome(base, tagConfig, op, namespaceName, workflowType, nexusoperationpb.OPERATION_STATUS_TIMED_OUT, closeTime, chasmnexus.NexusOperationTimeoutCount.With, metrics.TimeoutTypeTag(timeoutType))
64 > }
65
66 // emitOperationOutcome records the terminal outcome counter and the shared latency metrics for a
67 // closed operation. The outcome-specific counter is supplied as a metric definition's With method
68 // (e.g. NexusOperationSuccessCount.With), so each per-outcome recorder differs only by its counter
69 // and any extra counter tags (the timeout type, for timeouts).
70 func emitOperationOutcome(
71 base metrics.Handler,
72 tagConfig chasmnexus.NexusMetricTagConfig,
73 op Operation,
74 namespaceName, workflowType string,
75 status nexusoperationpb.OperationStatus,
76 closeTime time.Time,
77 withCounter func(metrics.Handler) metrics.CounterIface,
78 counterTags ...metrics.Tag,
79 > ) { metrics.go ×4
80 > handler := operationMetricsHandler(base, tagConfig, op, namespaceName, workflowType)
81 > withCounter(handler).Record(1, counterTags...)
82 > emitCompletionLatencies(handler, op, closeTime, metrics.OutcomeTag(strings.ToLower(status.String())))
83 > }
84
85 // emitCompletionLatencies emits schedule-to-close plus either start-to-close (operations that
86 // started) or schedule-to-start (sync / never-started), mirroring chasm/lib/nexusoperation's
87 // emitLatencyMetrics. It is shared by the per-outcome recorders above.
88 > func emitCompletionLatencies(handler metrics.Handler, op Operation, closeTime time.Time, outcomeTag metrics.Tag) { metrics.go ×4
89 > if op.ScheduledTime == nil {
90 return
91 }
92 > scheduledTime := op.ScheduledTime.AsTime() metrics.go ×4
93 > chasmnexus.NexusOperationScheduleToCloseLatency.With(handler).Record(closeTime.Sub(scheduledTime), outcomeTag)
94 > if op.StartedTime != nil {
95 > // Async operation that was started; schedule-to-start latency was emitted at start time. metrics.go ×1
96 > chasmnexus.NexusOperationStartToCloseLatency.With(handler).Record(closeTime.Sub(op.StartedTime.AsTime()), outcomeTag)
97 > } else { metrics.go ×4
98 > // Sync operation or operation that never started. metrics.go ×1
99 > chasmnexus.NexusOperationScheduleToStartLatency.With(handler).Record(closeTime.Sub(scheduledTime))
100 > }
101 }
102
103 // emitScheduleToStartLatency emits the schedule-to-start latency when an async operation starts.
104 func emitScheduleToStartLatency(
105 base metrics.Handler,
106 tagConfig chasmnexus.NexusMetricTagConfig,
107 op Operation,
108 namespaceName, workflowType string,
109 startedTime time.Time,
110 > ) { metrics.go ×2
111 > if op.ScheduledTime == nil {
112 return
113 }
114 > handler := operationMetricsHandler(base, tagConfig, op, namespaceName, workflowType) metrics.go ×2
115 > chasmnexus.NexusOperationScheduleToStartLatency.With(handler).Record(startedTime.Sub(op.ScheduledTime.AsTime()))
116 }