jaegertracing/jaeger · error

invalid parameters

Error message

invalid parameters

What it means

calculateTimeRange in the Elasticsearch metrics reader validates that a *metricstore.BaseQueryParameters pointer carries a non-nil EndTime and a non-nil Lookback before deriving the query window (start = EndTime - Lookback, extended by 10 minutes). If params itself is nil, or either required field is a nil pointer, it returns this error instead of dereferencing nil. It is raised before any Elasticsearch request is sent, so the metric query never executes.

Source

Thrown at internal/storage/metricstore/elasticsearch/reader.go:237

	span := r.queryLogger.TraceQuery(ctx, p.metricName)
	defer span.End()

	searchResult, err := r.queryBuilder.Execute(ctx, p.boolQuery, p.aggQuery, timeRange)
	if err != nil {
		err = fmt.Errorf("failed executing metrics query: %w", err)
		r.queryLogger.LogErrorToSpan(span, err)
		return nil, err
	}

	r.queryLogger.LogAndTraceResult(span, searchResult)

	// Return raw search result
	return searchResult, nil
}

func calculateTimeRange(params *metricstore.BaseQueryParameters) (TimeRange, error) {
	if params == nil || params.EndTime == nil || params.Lookback == nil {
		return TimeRange{}, errors.New("invalid parameters")
	}
	endTime := *params.EndTime
	startTime := endTime.Add(-*params.Lookback)
	extendedStartTime := startTime.Add(-10 * time.Minute)

	return TimeRange{
		startTimeMillis:         startTime.UnixMilli(),
		endTimeMillis:           endTime.UnixMilli(),
		extendedStartTimeMillis: extendedStartTime.UnixMilli(),
	}, nil
}

View on GitHub (pinned to 806f444784)

Solutions

  1. Set both EndTime and Lookback (non-nil pointers) on params.BaseQueryParameters before calling GetLatencies/GetCallRates/GetErrorRates.
  2. If you only have an end time, assign a sensible Lookback such as time.Duration pointed value (e.g. lookback := metricstore.LookbackFor(endTime) or a fixed 1h).
  3. Use the standard jaeger query HTTP handler paths, which populate defaults, instead of calling the metrics reader directly with partial options.
  4. Validate the options in your own code before invoking the reader so the failure is surfaced with context.

Example fix

// before
params := &metricstore.BaseQueryOptions{}
points, err := metricsReader.GetCallRates(ctx, params)
// after
end := time.Now()
lookback := time.Hour
params := &metricstore.BaseQueryOptions{
	BaseQueryParameters: &metricstore.BaseQueryParameters{
		EndTime:  &end,
		Lookback: &lookback,
	},
}
points, err := metricsReader.GetCallRates(ctx, params)
Defensive patterns

Strategy: validation

Validate before calling

func validMetricsParams(p *metricstore.BaseQueryParameters) bool {
	return p != nil && p.EndTime != nil && p.Lookback != nil
}
// call site:
if !validMetricsParams(opts.BaseQueryParameters) {
	return fmt.Errorf("metrics query requires EndTime and Lookback")
}

Type guard

func hasTimeRange(p *metricstore.BaseQueryParameters) bool {
	return p != nil && p.EndTime != nil && p.Lookback != nil
}

Prevention

When it happens

Trigger: Calling MetricsReader.GetLatencies, GetCallRates, or GetErrorRates with a *metricstore.BaseQueryOptions whose BaseQueryParameters is nil, has EndTime == nil, or has Lookback == nil. This typically happens when the caller constructs query options manually instead of through the query-plugin HTTP/gRPC layer, which normally defaults these fields.

Common situations: Embedding jaeger metrics reader in a custom service and building BaseQueryOptions by hand; forgetting to populate Lookback while only setting EndTime; a config/flags path that skips the default lookback (e.g. --query.frequency / lookback flags not applied); passing zero-value structs where pointers stay nil.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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