24
}
25
26
>
func (e *workerMetricsEmitter) emit(nsID namespace.ID, nsName namespace.Name, heartbeats []*workerpb.WorkerHeartbeat) {
worker_metrics_emitter.go
27
>
// The SDK aggregates all workers on the same Client into one heartbeat RPC, so
28
>
// len(heartbeats) approximates workers-per-process. It's per-Client-per-Namespace,
29
>
// not strictly per-process, but multiple Clients per process is uncommon in practice.
30
>
metrics.WorkerRegistryWorkersPerProcess.With(e.handler).Record(int64(len(heartbeats)))
31
>
32
>
enablePluginMetrics := e.config.EnablePluginMetrics != nil && e.config.EnablePluginMetrics()
33
>
enablePollerAutoscalingMetrics := e.config.EnablePollerAutoscalingMetrics != nil && e.config.EnablePollerAutoscalingMetrics()
34
>
enableStorageDriverMetrics := e.config.ExternalPayloadsEnabled != nil && e.config.ExternalPayloadsEnabled(nsName.String())
35
>
36
>
recordedPlugins := make(map[string]bool)
37
>
recordedDrivers := make(map[string]bool)
38
>
39
>
for _, hb := range heartbeats {
40
>
// Activity slots metric (always enabled)
41
>
if hb.ActivityTaskSlotsInfo != nil {
42
metrics.WorkerRegistryActivitySlotsUsed.With(e.handler).Record(int64(hb.ActivityTaskSlotsInfo.CurrentUsedSlots))
43
}
44
45
// Plugin metrics (if enabled)
47
for _, pluginInfo := range hb.Plugins {
48
pluginName := pluginInfo.Name