-
Notifications
You must be signed in to change notification settings - Fork 103
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
bbolt abstraction for statistic tracking #1659
base: main
Are you sure you want to change the base?
Conversation
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.
If I read this correct, I think:
- there's a new
statsstore
thing - which has a
GetStates
method that returns[]byte
I assume this is intended for use in a table/flare/etc. - (It's really the old logic from agent.GetStats)
- This is wired into knapsack, passed in via the initialization, and returned bare with
StorageStatTracker()
This feels a little weird to me. I'm not sure I have a simple suggestion though, I think it's highlighting something awkward that already existed. But it feels like this logic is spanning a bunch of places. And I wonder:
- Is it cleaner to keep passing the DB to knapsack, and puts the
GetStats
implementation there? (Probably not, knapsack tends to be a simple wrapper) - What would it look like if
GetStats
was part of the stores interface, they already have thedb
there. This feels good, but also that it might be a little awkward if we have multiple databases
I'm curious if you have more thoughts
Size int64 | ||
} | ||
|
||
type Stats struct { |
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.
type Stats struct { | |
type stats struct { |
I think? Or maybe even make it anonymous in the GetStats
method?
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.
yeah i'll get that cleaned up, ty!
This is all correct, the stats are currently used in slightly different ways across 2 flare checkups and in a table
I came to the same conclusion here- it seemed like an unnecessarily complex bit of logic to push up there and makes it just as easy to abuse usage going forward
This was my instinct too (and initial approach). Things got messy for a couple reasons:
Note that my opinion might be different if we decided that we could do away with the global stats, and instead just ask each store for |
I think if this all feels too complex to both of us, we should explore some other ways to get at it. My hunch is that we should expose it via knapsack. But I agree with you about all the ways it's messy |
This is the final bit of work towards removing the direct bbolt DB connection references from knapsack.
The remaining references are a bit different than the prior abstraction work so far - these are all held to pull stats from bbolt. This is done at a global (not bucket) level for the most part, so utilizing the same
KVStore
pattern here did not make sense.Instead, this replaces the direct
db
connection embedded in knapsack with a new interface type:StorageStatTracker
.The interface is intentionally vague (requires only that implementers can return a
SizeBytes
int64 andGetStats
json blob, because all current utilizations were tightly coupled to the bbolt logic itself. For now this seemed like the cleanest way to get where we want without overcomplicating potential future work (e.g. replacing bbolt usage in tests, changing storage methodology, etc.)