{"record":{"id":"fd19196204bf6bd7","repo":"weaviate/weaviate","slug":"opentelemetry-batch-timeout-must-be-greater-than","errorCode":null,"errorMessage":"opentelemetry: batch timeout must be greater than 0","messagePattern":"opentelemetry: batch timeout must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/telemetry/opentelemetry/errors.go","lineNumber":27,"sourceCode":"//  CONTACT: hello@weaviate.io\n//\n\npackage opentelemetry\n\nimport \"errors\"\n\nvar (\n\t// ErrEmptyServiceName is returned when the service name is empty\n\tErrEmptyServiceName = errors.New(\"opentelemetry: service name cannot be empty\")\n\n\t// ErrEmptyExporterEndpoint is returned when the exporter endpoint is empty\n\tErrEmptyExporterEndpoint = errors.New(\"opentelemetry: exporter endpoint cannot be empty\")\n\n\t// ErrInvalidSamplingRate is returned when the sampling rate is invalid\n\tErrInvalidSamplingRate = errors.New(\"opentelemetry: sampling rate must be between 0.0 and 1.0\")\n\n\t// ErrInvalidBatchTimeout is returned when the batch timeout is invalid\n\tErrInvalidBatchTimeout = errors.New(\"opentelemetry: batch timeout must be greater than 0\")\n\n\t// ErrInvalidBatchSize is returned when the batch size is invalid\n\tErrInvalidBatchSize = errors.New(\"opentelemetry: batch size must be greater than 0\")\n\n\t// ErrExporterNotSupported is returned when the exporter protocol is not supported\n\tErrExporterNotSupported = errors.New(\"opentelemetry: exporter protocol not supported\")\n)\n","sourceCodeStart":9,"sourceCodeEnd":35,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/telemetry/opentelemetry/errors.go#L9-L35","documentation":"ErrInvalidBatchTimeout is returned by the OpenTelemetry config's IsValid() when Config.BatchTimeout is zero or negative (config.go:132). The batch timeout controls how long the batch span/metric processor waits before flushing; a non-positive value would either never flush or immediately spin, so it is rejected.","triggerScenarios":"Setting the batch timeout to 0 or a negative duration in the OpenTelemetry configuration, e.g. parsing a duration string that failed and silently produced 0.","commonSituations":"Zero-value Config structs where the timeout field was never set; duration env vars parsed incorrectly (missing time unit); templates defaulting the field to 0.","solutions":["Set BatchTimeout to a positive duration, e.g. 5 * time.Second.","Check duration parsing of env/config values — a failed parse yields the zero value and triggers this error.","Rely on the library default if you do not need custom batching."],"exampleFix":"// before\ncfg := opentelemetry.Config{ServiceName: \"weaviate\", ExporterEndpoint: \"otel:4317\", BatchTimeout: 0}\n// after\ncfg := opentelemetry.Config{ServiceName: \"weaviate\", ExporterEndpoint: \"otel:4317\", BatchTimeout: 5 * time.Second}","handlingStrategy":"validation","validationCode":"if cfg.BatchTimeout <= 0 {\n\treturn fmt.Errorf(\"batch timeout must be > 0, got %v\", cfg.BatchTimeout)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.IsValid(); err != nil {\n\tif errors.Is(err, opentelemetry.ErrInvalidBatchTimeout) {\n\t\tcfg.BatchTimeout = 5 * time.Second\n\t}\n}","preventionTips":["Include time units when parsing duration env vars (use time.ParseDuration).","Guard against zero-value Config structs by validating before use.","Use library defaults when you don't need custom batch timings.","Log the parsed duration at startup to confirm the unit conversion."],"tags":["opentelemetry","configuration","batching"],"backgroundTag":"config-value-out-of-range","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}