{"record":{"id":"3a09cd3a5ca708df","repo":"apache/beam","slug":"enabletracecapturehook-s-not-registered","errorCode":null,"errorMessage":"EnableTraceCaptureHook: %s not registered","messagePattern":"EnableTraceCaptureHook: (.+?) not registered","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/x/hooks/perf/perf.go","lineNumber":185,"sourceCode":"}\n\nvar traceCaptureHookRegistry = make(map[string]CaptureHookFactory)\nvar enabledTraceCaptureHooks []string\n\n// RegisterTraceCaptureHook registers a CaptureHookFactory for the\n// supplied identifier. It panics if the same identifier is\n// registered twice.\nfunc RegisterTraceCaptureHook(name string, c CaptureHookFactory) {\n\tif _, exists := traceCaptureHookRegistry[name]; exists {\n\t\tpanic(fmt.Sprintf(\"RegisterTraceCaptureHook: %s registered twice\", name))\n\t}\n\ttraceCaptureHookRegistry[name] = c\n}\n\n// EnableTraceCaptureHook actives a registered profile capture hook for a given pipeline.\nfunc EnableTraceCaptureHook(name string, opts ...string) {\n\tif _, exists := traceCaptureHookRegistry[name]; !exists {\n\t\tpanic(fmt.Sprintf(\"EnableTraceCaptureHook: %s not registered\", name))\n\t}\n\n\tenc := hooks.Encode(name, opts)\n\tfor i, h := range enabledTraceCaptureHooks {\n\t\tn, _ := hooks.Decode(h)\n\t\tif h == n {\n\t\t\t// Rewrite the registration with the current arguments\n\t\t\tenabledTraceCaptureHooks[i] = enc\n\t\t\thooks.EnableHook(\"trace\", enabledTraceCaptureHooks...)\n\t\t\treturn\n\t\t}\n\t}\n\tenabledTraceCaptureHooks = append(enabledTraceCaptureHooks, enc)\n\thooks.EnableHook(\"trace\", enabledTraceCaptureHooks...)\n}\n\nvar heapCaptureHookRegistry = make(map[string]CaptureHookFactory)\nvar enabledHeapCaptureHooks []string","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/x/hooks/perf/perf.go#L167-L203","documentation":"EnableTraceCaptureHook checks traceCaptureHookRegistry for the given name and panics when it was never registered via RegisterTraceCaptureHook. This separates enabling (per pipeline/job) from registration (per binary/import), so enabling an unknown hook is a programmer/configuration error.","triggerScenarios":"Calling perf.EnableTraceCaptureHook(name, opts...) with a name absent from the trace hook registry — misspelled name, hook package not imported into the worker binary, or the option string carrying a stale hook identifier.","commonSituations":"Job options/flags referencing a trace hook that only exists in another binary; refactor renamed the hook but old option values persist; worker containers built without the instrumentation package.","solutions":["Blank-import the package that registers the trace hook (e.g. _ \".../hooks/perf/tracehook\") before enabling.","Match the enabled name exactly against the registered identifier.","Validate hook names coming from flags/job options against the registry.","Ensure the enabling binary and the worker binary both link the hook registration package."],"exampleFix":"// before\nperf.EnableTraceCaptureHook(\"tracing\", \"opts\") // panics: not registered\n// after\nimport _ \"github.com/apache/beam/sdks/go/pkg/beam/x/hooks/perf/tracehook\" // registers \"tracing\"\nperf.EnableTraceCaptureHook(\"tracing\", \"opts\")","handlingStrategy":"validation","validationCode":"import _ \"path/to/hook/that/registers/tracing\"\nconst traceHookName = \"tracing\" // shared constant with the registration site\nperf.EnableTraceCaptureHook(traceHookName)","typeGuard":null,"tryCatchPattern":"func enableTrace(name string, opts ...string) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"trace hook %q unavailable: %v\", name, r)\n        }\n    }()\n    perf.EnableTraceCaptureHook(name, opts...)\n}","preventionTips":["Blank-import the registering package wherever hooks are enabled.","Use shared constants for hook names instead of raw strings in flags.","Update launch scripts when hook identifiers change.","Document which binaries must link each hook package."],"tags":["go","apache-beam","configuration","missing-registration"],"backgroundTag":"missing-dependency","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}