Skip to content

Conversation

@StephenButtolph
Copy link
Contributor

Why this should be merged

As we convert some of our caches to be size based, the length of the cache is a useful metric.

How this works

Adds Len to the cache interface and tracks it in the metercacher

How this was tested

CI

Comment on lines +99 to +101
if c.elements == nil {
return 0
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: if resize() hasn't been called yet - c.elements may be nil

}

func (c *sizedLRU[_, _]) len() int {
return c.elements.Len()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the nil check here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no - elements is initialized in NewSizedLRU here

@StephenButtolph StephenButtolph merged commit 9ba776f into dev Aug 1, 2023
@StephenButtolph StephenButtolph deleted the add-cache-len-metrics branch August 1, 2023 00:54
@StephenButtolph StephenButtolph added this to the v1.10.6 milestone Aug 1, 2023
@StephenButtolph StephenButtolph added the monitoring This primarily focuses on logs, metrics, and/or tracing label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

monitoring This primarily focuses on logs, metrics, and/or tracing

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants