mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 00:22:19 -04:00
Address feedback
Signed-off-by: Carrie Edwards <edwrdscarrie@gmail.com>
This commit is contained in:
parent
7eee9e4f42
commit
a52617c0d2
5 changed files with 27 additions and 18 deletions
|
|
@ -139,7 +139,7 @@ func (c *FloatHistogramSTChunk) Appender() (Appender, error) {
|
|||
st: it.st,
|
||||
stDiff: it.stDiff,
|
||||
firstSTKnown: it.firstSTKnown,
|
||||
firstSTChangeOn: uint16(it.firstSTChangeOn),
|
||||
firstSTChangeOn: it.firstSTChangeOn,
|
||||
},
|
||||
}
|
||||
return a, nil
|
||||
|
|
@ -409,7 +409,13 @@ func (*FloatHistogramSTAppender) AppendHistogram(*HistogramAppender, int64, int6
|
|||
|
||||
// AppendFloatHistogram implements Appender for FloatHistogramSTAppender.
|
||||
func (a *FloatHistogramSTAppender) AppendFloatHistogram(prev *FloatHistogramAppender, st, t int64, fh *histogram.FloatHistogram, appendOnly bool) (Chunk, bool, Appender, error) {
|
||||
if a.NumSamples() == 0 {
|
||||
numSamples := a.NumSamples()
|
||||
|
||||
if numSamples == int(a.sampleCountMask()) {
|
||||
panic("chunk capacity exceeded")
|
||||
}
|
||||
|
||||
if numSamples == 0 {
|
||||
a.appendFloatHistogramST(st, t, fh)
|
||||
if fh.CounterResetHint == histogram.GaugeType {
|
||||
a.setCounterResetHeader(GaugeType)
|
||||
|
|
|
|||
|
|
@ -577,3 +577,7 @@ func TestFloatHistogramSTAppenderPreviousEmbeddedAppenderUsesSTHeader(t *testing
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, CounterReset, nextChunk.GetCounterResetHeader())
|
||||
}
|
||||
|
||||
func TestFloatHistogramSTChunkOverFlowPanics(t *testing.T) {
|
||||
testChunkOverFlowPanics(t, EncFloatHistogramST, ValFloatHistogram)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func (c *HistogramSTChunk) Appender() (Appender, error) {
|
|||
st: it.st,
|
||||
stDiff: it.stDiff,
|
||||
firstSTKnown: it.firstSTKnown,
|
||||
firstSTChangeOn: uint16(it.firstSTChangeOn),
|
||||
firstSTChangeOn: it.firstSTChangeOn,
|
||||
},
|
||||
}
|
||||
return a, nil
|
||||
|
|
@ -412,7 +412,13 @@ func (*HistogramSTAppender) AppendFloatHistogram(*FloatHistogramAppender, int64,
|
|||
|
||||
// AppendHistogram implements Appender for HistogramSTAppender.
|
||||
func (a *HistogramSTAppender) AppendHistogram(prev *HistogramAppender, st, t int64, h *histogram.Histogram, appendOnly bool) (Chunk, bool, Appender, error) {
|
||||
if a.NumSamples() == 0 {
|
||||
numSamples := a.NumSamples()
|
||||
|
||||
if numSamples == int(a.sampleCountMask()) {
|
||||
panic("chunk capacity exceeded")
|
||||
}
|
||||
|
||||
if numSamples == 0 {
|
||||
a.appendHistogramST(st, t, h)
|
||||
if h.CounterResetHint == histogram.GaugeType {
|
||||
a.setCounterResetHeader(GaugeType)
|
||||
|
|
|
|||
|
|
@ -574,3 +574,7 @@ func TestHistogramSTAppenderPreviousEmbeddedAppenderUsesSTHeader(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, CounterReset, nextChunk.GetCounterResetHeader())
|
||||
}
|
||||
|
||||
func TestHistogramSTChunkOverFlowPanics(t *testing.T) {
|
||||
testChunkOverFlowPanics(t, EncHistogramST, ValHistogram)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const (
|
|||
|
||||
type stEncoder struct {
|
||||
st, stDiff int64
|
||||
firstSTChangeOn uint16
|
||||
firstSTChangeOn uint8
|
||||
firstSTKnown bool
|
||||
}
|
||||
|
||||
|
|
@ -48,18 +48,7 @@ func writeHeaderFirstSTChangeOn(b []byte, firstSTChangeOn uint16) {
|
|||
}
|
||||
|
||||
func readSTHeader(b []byte) (firstSTKnown bool, firstSTChangeOn uint8) {
|
||||
if b[0] == 0x00 {
|
||||
return false, 0
|
||||
}
|
||||
if b[0] == 0x80 {
|
||||
return true, 0
|
||||
}
|
||||
mask := byte(0x80)
|
||||
if b[0]&mask != 0 {
|
||||
firstSTKnown = true
|
||||
}
|
||||
mask = 0x7F
|
||||
return firstSTKnown, b[0] & mask
|
||||
return b[0]&0x80 != 0, b[0] & 0x7F
|
||||
}
|
||||
|
||||
// encode writes the start timestamp data for the current histogram or float histogram sample and updates the encoder state.
|
||||
|
|
@ -92,7 +81,7 @@ func (e *stEncoder) encode(b *bstream, num uint16, curT, prevT, st int64) {
|
|||
if e.firstSTChangeOn == 0 {
|
||||
if st != e.st || num-1 == maxFirstSTChangeOn {
|
||||
stDiff := prevT - st
|
||||
e.firstSTChangeOn = num - 1
|
||||
e.firstSTChangeOn = uint8(num - 1)
|
||||
writeHeaderFirstSTChangeOn(b.bytes()[histogramHeaderSize-1:], num-1)
|
||||
putVarbitInt(b, stDiff)
|
||||
e.stDiff = stDiff
|
||||
|
|
|
|||
Loading…
Reference in a new issue