Skip to content
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

pyroscpoe.scrape: collect delta map sizes metric #2862

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

korniltsev
Copy link
Contributor

@korniltsev korniltsev commented Feb 27, 2025

PR Description

Introduce new pyroscope_delta_map_size metric reflecting the size of the DeltaMaps

example:

pyroscope_delta_map_size{aggregation="alloy-ns",component_id="pyroscope.scrape.pyroscope",component_path="/"} 1174
pyroscope_delta_map_size{aggregation="pyroscope-ns",component_id="pyroscope.scrape.pyroscope",component_path="/"} 3670

Which issue(s) this PR fixes

The metric will help investigating who's consuming memory #2840

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@korniltsev korniltsev requested a review from Copilot March 3, 2025 07:44

Choose a reason for hiding this comment

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

PR Overview

This PR adds a new Prometheus metric to track the size of the delta map used in the delta profiling workflow. The key changes include:

  • Introducing a new delta metric collector ("pyroscope_delta_map_size") registered with Prometheus.
  • Updating the Manager to accept a Registerer and utilize the new collector.
  • Enhancing tests to validate that the new delta map size metric is correctly reported.

Reviewed Changes

File Description
internal/component/pyroscope/scrape/delta_metric_collector.go Added a collector for the delta map size metric.
internal/component/pyroscope/scrape/delta_profiles_manager_test.go Updated tests to verify the new metric collection.
internal/component/pyroscope/scrape/internal/fastdelta/fd.go Added a DeltaMapSize function with documentation.
internal/component/pyroscope/scrape/scrape_loop.go Introduced activeScrapeLoops to iterate active scraping loops.
internal/component/pyroscope/scrape/manager.go Refactored NewManager to accept a Registerer and register the new collector.
internal/component/pyroscope/scrape/manager_test.go Updated test to support the new NewManager signature.
internal/component/pyroscope/scrape/delta_profiles.go Updated the delta appender to store the current delta map size.
internal/component/pyroscope/scrape/scrape.go Updated the NewManager invocation with the Registerer parameter.

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

internal/component/pyroscope/scrape/delta_profiles.go:128

  • [nitpick] Review the placement of updating lastDeltaMapSize before the initialization check. Ensure that storing the delta map size on the first sample (which is subsequently skipped) aligns with the intended metric reporting.
d.lastDeltaMapSize.Store(int64(d.delta.DeltaMapSize()))
@korniltsev korniltsev force-pushed the pyroscope-scrape-collect-delta-map-sizes branch from 44365b0 to b92f8cb Compare March 3, 2025 08:13
return &deltaMetricCollector{
manager: manager,
desc: prometheus.NewDesc("pyroscope_delta_map_size", "Size of the DeltaMap", []string{"aggregation"}, nil),
label: "namespace",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: discuss how to not hardcode this

@korniltsev korniltsev marked this pull request as ready for review March 3, 2025 08:27
@korniltsev korniltsev requested review from a team as code owners March 3, 2025 08:27
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