-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
fix: Metrics cleanup based on syn module #1233
fix: Metrics cleanup based on syn module #1233
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
69289d3
to
866ad44
Compare
Adds a new worker that will cleanup metrics based on our syn information to reduce the amount of data pulled by Prometheus.
866ad44
to
17f3fdc
Compare
tenant_ids = :ets.select(@table_name, @tenant_id_spec) | ||
|
||
:ets.select(@metrics_table, @filter_spec) | ||
|> Enum.uniq() | ||
|> Enum.reject(fn tenant_id -> tenant_id in tenant_ids end) | ||
|> Enum.each(fn tenant_id -> delete_metric(tenant_id) end) |
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.
as an alternative
tenant_ids = :ets.select(@table_name, @tenant_id_spec) | |
:ets.select(@metrics_table, @filter_spec) | |
|> Enum.uniq() | |
|> Enum.reject(fn tenant_id -> tenant_id in tenant_ids end) | |
|> Enum.each(fn tenant_id -> delete_metric(tenant_id) end) | |
:ets.foldl( | |
fn {{_, tags}, _}, acc -> | |
if tags[:tenant], | |
do: delete_metric(tags[:tenant]) + acc, | |
else: acc | |
end, | |
0, | |
@table_name | |
) |
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 think I prefer the simpler readability since it will be handling a low amount of data... at least for now
Deletes all metrics that contain the given tenant. | ||
""" | ||
@spec delete_metric(String.t()) :: :ok | ||
def delete_metric(tenant) do |
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.
:ets.select_delete returns a count of deleted items, which can be useful
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.
yes but I was ignoring it for now as we don't have a good use case for it now
🎉 This PR is included in version 2.33.56 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What kind of change does this PR introduce?
Adds a new worker that will cleanup metrics based on our syn information to reduce the amount of data pulled by Prometheus.