Skip to content

Commit

Permalink
[chore] [translator/prometheusremotewrite] ensure unknown reset hint
Browse files Browse the repository at this point in the history
Ensure that native histogram reset hint is UNKNWON and document reasoning.
Related: #28663

Signed-off-by: György Krajcsovits <[email protected]>
  • Loading branch information
krajorama committed Nov 17, 2023
1 parent c3b2997 commit afbe19c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/translator/prometheusremotewrite/histograms.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ func exponentialToNativeHistogram(p pmetric.ExponentialHistogramDataPoint) (prom
nSpans, nDeltas := convertBucketsLayout(p.Negative(), scaleDown)

h := prompb.Histogram{
Schema: scale,
// The counter reset detection must be compatible with Prometheus to
// safely set ResetHint to NO. This is not ensured currently.
// Sending a sample that triggers counter reset but with ResetHint==NO
// would lead to Prometheus panic as it does not double check the hint.
// Thus we're explicitly saying UNKNOWN here, which is always safe.
// TODO: using created time stamp should be accurate, but we
// need to know here if it was used for the detection.
// Ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/28663#issuecomment-1810577303
// Counter reset detection in Prometheus: https://github.com/prometheus/prometheus/blob/f997c72f294c0f18ca13fa06d51889af04135195/tsdb/chunkenc/histogram.go#L232
ResetHint: prompb.Histogram_UNKNOWN,
Schema: scale,

ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: p.ZeroCount()},
// TODO use zero_threshold, if set, see
Expand Down

0 comments on commit afbe19c

Please sign in to comment.