{"record":{"id":"1a588a8db03e1e55","repo":"jaegertracing/jaeger","slug":"latency-unit-must-be-ms-or-s-not-q","errorCode":null,"errorMessage":"latency_unit must be \"ms\" or \"s\", not %q","messagePattern":"latency_unit must be \"ms\" or \"s\", not %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/promcfg/config.go","lineNumber":38,"sourceCode":"\n\tTokenFilePath            string `mapstructure:\"token_file_path\"`\n\tTokenOverrideFromContext bool   `mapstructure:\"token_override_from_context\"`\n\n\tMetricNamespace   string `mapstructure:\"metric_namespace\"`\n\tLatencyUnit       string `mapstructure:\"latency_unit\"`\n\tNormalizeCalls    bool   `mapstructure:\"normalize_calls\"`\n\tNormalizeDuration bool   `mapstructure:\"normalize_duration\"`\n\t// ExtraQueryParams is used to provide extra parameters to be appended\n\t// to the URL of queries going out to the metrics backend.\n\tExtraQueryParams map[string]string `mapstructure:\"extra_query_parameters\"`\n}\n\nfunc (c *Configuration) Validate() error {\n\tif _, err := govalidator.ValidateStruct(c); err != nil {\n\t\treturn err\n\t}\n\tif u := c.LatencyUnit; u != \"\" && u != \"ms\" && u != \"s\" {\n\t\treturn fmt.Errorf(`latency_unit must be \"ms\" or \"s\", not %q`, u)\n\t}\n\treturn nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":42,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/config/promcfg/config.go#L20-L42","documentation":"Configuration.Validate() in the Prometheus config package first runs struct validation, then explicitly checks that the LatencyUnit field is either \"ms\" or \"s\" (or empty). Any other string is rejected because downstream latency histogram units must map to a known time unit. This prevents silently emitting metrics with an unrecognized unit suffix.","triggerScenarios":"Calling Configuration.Validate() (directly or via NewCluster) when c.LatencyUnit is set to a non-empty string other than \"ms\" or \"s\", e.g. \"ms \" with whitespace, \"MS\", \"seconds\", or \"msec\".","commonSituations":"Hand-editing a YAML/flag config and typing 'millis' or 'sec' for latency_unit; copying a config from another project that uses different unit strings; environment-variable interpolation producing an unexpected value.","solutions":["Set latency_unit to exactly \"ms\" or \"s\" in the configuration","Leave latency_unit empty (\"\") to use the default","Trim whitespace and fix casing in the config value (validation is case-sensitive)","Call Validate() early at startup so a bad value fails fast instead of at runtime"],"exampleFix":"// before\ncfg := promcfg.Configuration{LatencyUnit: \"millis\"}\n// after\ncfg := promcfg.Configuration{LatencyUnit: \"ms\"}","handlingStrategy":"validation","validationCode":"if cfg.LatencyUnit != \"\" && cfg.LatencyUnit != \"ms\" && cfg.LatencyUnit != \"s\" {\n    return fmt.Errorf(\"invalid latency_unit %q; must be \\\"ms\\\" or \\\"s\\\"\", cfg.LatencyUnit)\n}\nif err := cfg.Validate(); err != nil { return err }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ever assign \"ms\" or \"s\" to LatencyUnit; prefer constants","Leave the field empty to accept the default","Call Validate() at config-load time, before constructing the cluster","Beware config layers that append whitespace or change casing"],"tags":["config","validation","prometheus"],"backgroundTag":"invalid-config-value","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}