grafana/k6 · error
failed to convert Native Histogram to the related Protobuf
Error message
failed to convert Native Histogram to the related Protobuf: %w
What it means
Converting a Prometheus native histogram into its protobuf representation failed when h.Write serialized the histogram into a dto.Metric. This path panics — it's an internal invariant violation, not user configuration.
Solutions
- Capture the panic output and report a bug to k6 with the script
- Disable trendAsNativeHistogram (or the native-histograms feature flag) to avoid the code path
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/output/prometheusrw/remotewrite/trend.go:201 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/9ab180dcf3d0aad1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/output/prometheusrw/remotewrite/trend.go:201
suffix := baseUnit(series.Metric.Contains)
labels := MapSeries(series, suffix)
timestamp := t.UnixMilli()
return []*prompb.TimeSeries{
{
Labels: labels,
Histograms: []*prompb.Histogram{
histogramToHistogramProto(timestamp, sink.H),
},
},
}
}
func histogramToHistogramProto(timestamp int64, h prometheus.Histogram) *prompb.Histogram {
// TODO: research more if a better way is possible.
metric := &dto.Metric{}
if err := h.Write(metric); err != nil {
panic(fmt.Errorf("failed to convert Native Histogram to the related Protobuf: %w", err))
}
hmetric := metric.Histogram
return &prompb.Histogram{
Count: &prompb.Histogram_CountInt{CountInt: *hmetric.SampleCount},
Sum: *hmetric.SampleSum,
Schema: *hmetric.Schema,
ZeroThreshold: *hmetric.ZeroThreshold,
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: *hmetric.ZeroCount},
NegativeSpans: toBucketSpanProto(hmetric.NegativeSpan),
NegativeDeltas: hmetric.NegativeDelta,
PositiveSpans: toBucketSpanProto(hmetric.PositiveSpan),
PositiveDeltas: hmetric.PositiveDelta,
Timestamp: timestamp,
}
}
func toBucketSpanProto(s []*dto.BucketSpan) []*prompb.BucketSpan {View on GitHub (pinned to 01ffac6f24)