Skip to content

Conversation

@sprsquish
Copy link

Reduce work based on desired metrics

Description

  • Adds an option: METRICS_ALLOWLIST that dictates only the metrics required. This option cannot be used with METRICS_DENYLIST.
  • Refactors the code to do only the work required for the metrics being requested.
  • Only pull the list of zones once if CF_ZONES is provided.
  • Refactor label creation to reduce allocations.

The most significant changes made are refactoring metrics management. The refactor serves to eliminate API calls for metrics that are not required. For instance, previously, if I did not want to expose r2 metrics, the exporter would only neglect to register the metric with Prometheus, but still make the graphql request. The refactored code puts the responsibility on each fetch function to determine if there's any need for the metrics it provides. If there is no need, it returns early without making any calls.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Other (please describe):

Testing

  • I have run make pr-tests and all tests pass
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Before Submitting

Please ensure you have completed the following before submitting your PR:

# Run comprehensive tests
make pr-tests

If the above command fails, please fix the issues before submitting your PR.

Additional Notes

Add any other context about the pull request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant