{"record":{"id":"c979b2ec79e87e93","repo":"jaegertracing/jaeger","slug":"cannot-create-metrics-factory-w","errorCode":null,"errorMessage":"cannot create metrics factory: %w","messagePattern":"cannot create metrics factory: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/flags/service.go","lineNumber":85,"sourceCode":"\n\tsFlags := new(SharedFlags).InitFromViper(v)\n\tnewProdConfig := zap.NewProductionConfig()\n\tnewProdConfig.Sampling = nil\n\tlogger, err := sFlags.NewLogger(newProdConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create logger: %w\", err)\n\t}\n\ts.Logger = logger\n\tgrpclog.SetLoggerV2(zapgrpc.NewLogger(\n\t\tlogger.WithOptions(\n\t\t\tzap.AddCallerSkip(5), // ensure the actual caller:lineNo is shown\n\t\t),\n\t))\n\n\tmetricsBuilder := new(metricsbuilder.Builder).InitFromViper(v)\n\tmetricsFactory, err := metricsBuilder.CreateMetricsFactory(\"\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create metrics factory: %w\", err)\n\t}\n\ts.MetricsFactory = metricsFactory\n\n\tif err = s.Admin.initFromViper(v, s.Logger); err != nil {\n\t\treturn fmt.Errorf(\"cannot initialize admin server: %w\", err)\n\t}\n\tif h := metricsBuilder.Handler(); h != nil {\n\t\troute := metricsBuilder.HTTPRoute\n\t\ts.Logger.Info(\"Mounting metrics handler on admin server\", zap.String(\"route\", route))\n\t\ts.Admin.Handle(route, h)\n\t}\n\n\t// Mount expvar routes on different backends\n\tif metricsBuilder.Backend != \"expvar\" {\n\t\ts.Logger.Info(\"Mounting expvar handler on admin server\", zap.String(\"route\", \"/debug/vars\"))\n\t\ts.Admin.Handle(\"/debug/vars\", expvar.Handler())\n\t}\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/internal/flags/service.go#L67-L103","documentation":"This error wraps any failure from metricsBuilder.CreateMetricsFactory(\"\") while the Jaeger service is starting up. The metrics builder reads the `jaeger.metrics` configuration section from viper and instantiates the chosen metrics backend (prometheus, expvar, or none). If the backend cannot be constructed — typically because its configuration is invalid or the registry cannot be created — the process refuses to start and returns this wrapped error.","triggerScenarios":"Calling flags.Start() (via the jaeger all-in-one or collector binary) with a metrics config that names a backend the builder fails to instantiate, e.g. jaeger.metrics.backend=prometheus with invalid fields, or an unknown/unsupported backend value.","commonSituations":"Operators set a metrics backend in the YAML/CLI config with a typo or an option belonging to a different Jaeger version; the Prometheus factory fails while connecting to or constructing its registry; an empty backend string combined with malformed sub-config.","solutions":["Fix the `jaeger.metrics` section in your config so the chosen backend (prometheus/expvar/none) has only valid options for your Jaeger version","Set jaeger.metrics.backend to `none` (or omit it) to start without a metrics backend and confirm the rest of the service boots","Read the wrapped `%w` cause in the log line — it names the underlying metrics-backend error and points at the bad field","Upgrade/downgrade Jaeger so the metrics config schema matches what your config file was written for"],"exampleFix":"// before (config.yaml)\njaeger:\n  metrics:\n    backend: promethus\n    prometheus:\n      timerType: bogus\n// after\njaeger:\n  metrics:\n    backend: prometheus\n    prometheus:\n      timerType: histogram","handlingStrategy":"validation","validationCode":"import \"github.com/jaegertracing/jaeger/cmd/internal/flags\"\n// Before Start, pre-parse and sanity-check the metrics config\nvar mCfg metricsbuilder.Config\nif err := v.UnmarshalKey(\"jaeger.metrics\", &mCfg); err != nil {\n    return fmt.Errorf(\"invalid jaeger.metrics config: %w\", err)\n}\nswitch mCfg.Backend {\ncase \"\", \"prometheus\", \"expvar\", \"none\":\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported jaeger.metrics.backend: %q\", mCfg.Backend)\n}","typeGuard":null,"tryCatchPattern":"if err := svc.Start(v); err != nil {\n    var wrapped interface{ Unwrap() error }\n    if errors.As(err, &target) { /* inspect underlying metrics backend error */ }\n    log.Fatalf(\"startup failed: %v\", err)\n}","preventionTips":["Validate the jaeger.metrics section (backend name and options) against your Jaeger version's schema before deploy","Keep jaeger.metrics minimal; omit it to get defaults","Use config-print/validation tooling to render the effective config at boot","Pin config templates to the Jaeger release you deploy"],"tags":["config","metrics","startup"],"backgroundTag":"invalid-config-value","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}