jaegertracing/jaeger · error

Field [%s]: Bucket [%s] could not be parsed as duration in '

Error message

Field [%s]: Bucket [%s] could not be parsed as duration in 'buckets' string [%s]

What it means

metrics.Init() parses the `buckets` tag for *Timer fields by splitting on commas and calling time.ParseDuration on each entry. Any bucket entry that is not a valid Go duration (e.g. '100' without a unit) causes this error naming the field, the bucket, and the whole buckets string.

Source

Thrown at internal/metrics/metrics.go:76

			for tagPair := range strings.SplitSeq(tagString, ",") {
				tag := strings.Split(tagPair, "=")
				if len(tag) != 2 {
					return fmt.Errorf(
						"Field [%s]: Tag [%s] is not of the form key=value in 'tags' string [%s]",
						field.Name, tagPair, tagString,
					)
				}
				tags[tag[0]] = tag[1]
			}
		}
		if bucketString := field.Tag.Get("buckets"); bucketString != "" {
			switch {
			case field.Type.AssignableTo(timerPtrType):
				bucketValues := strings.Split(bucketString, ",")
				for _, bucket := range bucketValues {
					d, err := time.ParseDuration(bucket)
					if err != nil {
						return fmt.Errorf(
							"Field [%s]: Bucket [%s] could not be parsed as duration in 'buckets' string [%s]",
							field.Name, bucket, bucketString,
						)
					}
					timerBuckets = append(timerBuckets, d)
				}
			case field.Type.AssignableTo(histogramPtrType):
				bucketValues := strings.Split(bucketString, ",")
				for _, bucket := range bucketValues {
					b, err := strconv.ParseFloat(bucket, 64)
					if err != nil {
						return fmt.Errorf(
							"Field [%s]: Bucket [%s] could not be converted to float64 in 'buckets' string [%s]",
							field.Name, bucket, bucketString,
						)
					}
					histogramBuckets = append(histogramBuckets, b)
				}

View on GitHub (pinned to 806f444784)

Solutions

  1. Add a duration unit to the offending bucket (e.g. '50' -> '50ms')
  2. Remove empty segments and stray commas from the buckets string
  3. Use valid Go duration syntax: 1ms, 100ms, 1s, 2m
  4. Validate the whole string with time.ParseDuration on each comma-separated part before running

Example fix

// before
Duration *Timer `metric:"dur" buckets:"1,10,100"`
// after
Duration *Timer `metric:"dur" buckets:"1ms,10ms,100ms"`
Defensive patterns

Strategy: validation

Validate before calling

func checkTimerBuckets(s string) error {
    for _, b := range strings.Split(s, ",") {
        if _, err := time.ParseDuration(b); err != nil {
            return fmt.Errorf("bad duration bucket %q", b)
        }
    }
    return nil
}

Try / catch

if err := metrics.Init(&m); err != nil {
    if strings.Contains(err.Error(), "could not be parsed as duration") {
        // fix the buckets string on the named field
    }
    return err
}

Prevention

When it happens

Trigger: A *Timer field with `buckets:"..."` containing an entry time.ParseDuration cannot parse, such as `buckets:"1ms,50,1s"` or `buckets:"10ms,"` (empty segment).

Common situations: Writing bare numbers for timer buckets forgetting duration units (ms, s); typos like '1ms ' with trailing space; trailing commas from copy-paste.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/2f948216b1021fcb. Report an issue: GitHub.