{"record":{"id":"66600709ad8679a1","repo":"thanos-io/thanos","slug":"tracing-failed","errorCode":null,"errorMessage":"tracing failed","messagePattern":"tracing failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/thanos/main.go","lineNumber":115,"sourceCode":"\t{\n\t\tvar (\n\t\t\tctx             = context.Background()\n\t\t\tcloser          io.Closer\n\t\t\tconfContentYaml []byte\n\t\t)\n\n\t\tconfContentYaml, err = tracingConfig.Content()\n\t\tif err != nil {\n\t\t\tlevel.Error(logger).Log(\"msg\", \"getting tracing config failed\", \"err\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tif len(confContentYaml) == 0 {\n\t\t\ttracer = client.NoopTracer()\n\t\t} else {\n\t\t\ttracer, closer, err = client.NewTracer(ctx, logger, metrics, confContentYaml)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, errors.Wrapf(err, \"tracing failed\"))\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\n\t\t// This is bad, but Prometheus does not support any other tracer injections than just global one.\n\t\t// TODO(bplotka): Work with basictracer to handle gracefully tracker mismatches, and also with Prometheus to allow\n\t\t// tracer injection.\n\t\topentracing.SetGlobalTracer(tracer)\n\n\t\tctx, cancel := context.WithCancel(ctx)\n\t\tg.Add(func() error {\n\t\t\t<-ctx.Done()\n\t\t\treturn ctx.Err()\n\t\t}, func(error) {\n\t\t\tif closer != nil {\n\t\t\t\tif err := closer.Close(); err != nil {\n\t\t\t\t\tlevel.Warn(logger).Log(\"msg\", \"closing tracer failed\", \"err\", err)\n\t\t\t\t}","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/main.go#L97-L133","documentation":"Raised at Thanos binary startup when initializing the distributed tracer from the provided tracing config YAML fails. The error is printed to stderr and the process exits immediately with status 1, since tracing is required before serving. Common clients: Jaeger. The underlying cause (bad config, exporter connection setup) is wrapped.","triggerScenarios":"--tracing.config (or tracing.config-file) content is non-empty and client.NewTracer fails: invalid YAML, unknown tracer type, missing required fields (e.g., jaeger endpoint), or failure connecting/configuring the exporter.","commonSituations":"Operator supplies tracing config referencing jaeger with unreachable agent/collector — depending on client, this can fail eagerly; typo in config keys; deprecated tracing config schema after Thanos upgrade; empty config correctly falls back to NoopTracer so only non-empty bad config triggers this.","solutions":["Validate the tracing config YAML against the tracing.Config schema (type: jaeger, service_name, etc.) for your Thanos version.","Start with an empty/no --tracing.config to confirm the binary runs (NoopTracer), then add tracing incrementally.","Check Jaeger endpoint/agent address reachability and fix host:port or sampler params in the config.","Remove deprecated tracing fields per the Thanos release notes if you upgraded and the schema changed."],"exampleFix":"// before\n// tracing:\n//   type: jaeger\n//   config:\n//     endpoint: bad-host:14268\n// after\n// tracing:\n//   type: jaeger\n//   service_name: thanos-query\n//   config:\n//     endpoint: jaeger-collector.monitoring.svc:14268","handlingStrategy":"try-catch","validationCode":"var tc tracing.Config\nif err := yaml.Unmarshal(confContentYaml, &tc); err != nil { return fmt.Errorf(\"tracing config invalid: %w\", err) }\nif tc.Type == \"\" && len(confContentYaml) > 0 { return errors.New(\"tracing.type is required when tracing config is provided\") }","typeGuard":null,"tryCatchPattern":"tracer, closer, err = client.NewTracer(ctx, logger, metrics, confContentYaml)\nif err != nil {\n    logger.Error(\"tracing failed, continuing without tracing\", \"err\", err)\n    tracer, closer = client.NoopTracer(), nil // optional: degrade instead of exit\n}","preventionTips":["Validate tracing config YAML against the tracing.Config schema in CI.","Only supply --tracing.config when tracing is actually needed; empty means NoopTracer.","Confirm Jaeger/collector endpoints are reachable from the deployment before enabling.","Re-check tracing schema after Thanos upgrades (breaking changes documented in release notes)."],"tags":["tracing","config","startup","thanos"],"backgroundTag":"module-init-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}