Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Mar 13, 2025

When using setdefault(), if an object already existed for that key, a MetricFetcher will be created anyways, only to be discarded right after it was created.

@Copilot Copilot AI review requested due to automatic review settings March 13, 2025 13:54
@llucax llucax requested a review from a team as a code owner March 13, 2025 13:54
@llucax llucax requested review from Marenz and removed request for a team March 13, 2025 13:54
@github-actions github-actions bot added the part:data-pipeline Affects the data pipeline label Mar 13, 2025
@llucax llucax requested a review from shsms March 13, 2025 13:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to avoid the unnecessary creation of a MetricFetcher instance when one already exists for the given key in the _metric_fetchers dictionary.

  • Replaces the use of setdefault() with a get()-and-check pattern in push_metric().
  • Ensures that a new MetricFetcher is only created when none is already present, preventing wasted computation.

When using `setdefault()`,  if an object already existed for that key,
a `MetricFetcher` will be created anyways, only to be discarded right
after it was created.

Signed-off-by: Leandro Lucarella <[email protected]>
@llucax llucax force-pushed the dangling-fetcher branch from 518c0bf to 364372d Compare March 13, 2025 13:56
@llucax llucax self-assigned this Mar 13, 2025
@github-actions github-actions bot added the part:docs Affects the documentation label Mar 13, 2025
@llucax llucax added type:bug Something isn't working and removed part:docs Affects the documentation labels Mar 13, 2025
@llucax llucax moved this from To do to Review in progress in Python SDK Roadmap Mar 13, 2025
@llucax llucax added this to the v1.0.0-rc1800 milestone Mar 13, 2025
@github-project-automation github-project-automation bot moved this from Review in progress to Review approved in Python SDK Roadmap Mar 17, 2025
@llucax llucax added this pull request to the merge queue Mar 17, 2025
Merged via the queue into frequenz-floss:v1.x.x with commit 83b8654 Mar 17, 2025
7 checks passed
@llucax llucax deleted the dangling-fetcher branch March 17, 2025 11:13
@github-project-automation github-project-automation bot moved this from Review approved to Done in Python SDK Roadmap Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:data-pipeline Affects the data pipeline type:bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants