-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staleness batch #6355
Staleness batch #6355
Changes from all commits
3f39be0
b437d52
31200ee
00e2219
3b312ce
cc74807
a4fe8d2
ecdc21f
364f9c0
0ab9b67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ import ( | |
"github.com/prometheus/prometheus/model/histogram" | ||
"github.com/prometheus/prometheus/model/labels" | ||
"github.com/prometheus/prometheus/model/metadata" | ||
"github.com/prometheus/prometheus/model/value" | ||
"github.com/prometheus/prometheus/storage" | ||
) | ||
|
||
|
@@ -80,8 +79,9 @@ func WithHistogramHook(f func(ref storage.SeriesRef, l labels.Labels, t int64, h | |
// Appender satisfies the Appendable interface. | ||
func (f *Interceptor) Appender(ctx context.Context) storage.Appender { | ||
app := &interceptappender{ | ||
interceptor: f, | ||
ls: f.ls, | ||
interceptor: f, | ||
ls: f.ls, | ||
stalenessTrackers: make([]labelstore.StalenessTracker, 0), | ||
} | ||
if f.next != nil { | ||
app.child = f.next.Appender(ctx) | ||
|
@@ -90,9 +90,10 @@ func (f *Interceptor) Appender(ctx context.Context) storage.Appender { | |
} | ||
|
||
type interceptappender struct { | ||
interceptor *Interceptor | ||
child storage.Appender | ||
ls labelstore.LabelStore | ||
interceptor *Interceptor | ||
child storage.Appender | ||
ls labelstore.LabelStore | ||
stalenessTrackers []labelstore.StalenessTracker | ||
} | ||
|
||
var _ storage.Appender = (*interceptappender)(nil) | ||
|
@@ -102,13 +103,11 @@ func (a *interceptappender) Append(ref storage.SeriesRef, l labels.Labels, t int | |
if ref == 0 { | ||
ref = storage.SeriesRef(a.ls.GetOrAddGlobalRefID(l)) | ||
} | ||
|
||
if value.IsStaleNaN(v) { | ||
a.ls.AddStaleMarker(uint64(ref), l) | ||
} else { | ||
// Tested this to ensure it had no cpu impact, since it is called so often. | ||
a.ls.RemoveStaleMarker(uint64(ref)) | ||
} | ||
a.stalenessTrackers = append(a.stalenessTrackers, labelstore.StalenessTracker{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We create a That way there will be less work and structs to create, the code will get simpler too I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel those are owned by two different things. Mainly the last marked state should really only be set by the labelstore itself and exposing that field feels off. This gets cleaned up slightly in the next PR. |
||
GlobalRefID: uint64(ref), | ||
Labels: l, | ||
Value: v, | ||
}) | ||
|
||
if a.interceptor.onAppend != nil { | ||
return a.interceptor.onAppend(ref, l, t, v, a.child) | ||
|
@@ -121,6 +120,7 @@ func (a *interceptappender) Append(ref storage.SeriesRef, l labels.Labels, t int | |
|
||
// Commit satisfies the Appender interface. | ||
func (a *interceptappender) Commit() error { | ||
a.ls.TrackStaleness(a.stalenessTrackers) | ||
if a.child == nil { | ||
return nil | ||
} | ||
|
@@ -129,6 +129,7 @@ func (a *interceptappender) Commit() error { | |
|
||
// Rollback satisfies the Appender interface. | ||
func (a *interceptappender) Rollback() error { | ||
a.ls.TrackStaleness(a.stalenessTrackers) | ||
if a.child == nil { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing some context here, but don't we need similar staleness tracking for AppendExemplar and AppendHistogram?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do but it never had it so keeping the pr small. I will have 2-3 more prs incoming.