Skip to content

feat: annotate sampled profiles #4375

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

Merged
merged 2 commits into from
Aug 15, 2025
Merged

Conversation

aleks-p
Copy link
Contributor

@aleks-p aleks-p commented Aug 14, 2025

Annotating profiles that are subject to distributor sampling. Similar to #3956, with a bit of refactoring to make things cleaner. The annotations will allow sampling to be visualized in profiling UIs and in the future adjust metrics generated from profiles (cc @alsoba13).

@aleks-p aleks-p requested a review from alsoba13 as a code owner August 14, 2025 20:01
PeriodLimitMb int `json:"periodLimitMb"`
LimitResetTime int64 `json:"limitResetTime"`
SamplingPeriodSec int `json:"samplingPeriodSec"`
SamplingRequests int `yaml:"samplingRequests"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, good thing is it hasn't been used yet :)

Copy link
Collaborator

@korniltsev korniltsev left a comment

Choose a reason for hiding this comment

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

lgtm

@korniltsev korniltsev requested a review from Copilot August 15, 2025 04:06
Copy link

@Copilot 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 adds support for annotating sampled profiles with distributor sampling information. This allows profiling UIs to visualize sampling and enables future metrics adjustments based on sampling data.

Key changes:

  • Introduces a new annotation system for tracking sampling sources with usage group and probability information
  • Refactors existing throttling annotations to use a centralized annotation package
  • Updates sampling logic to return sampling source information instead of just usage group matches

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/distributor/sampling/config.go Adds Source struct to track sampling metadata
pkg/distributor/annotation/annotation.go New shared annotation constants and types
pkg/distributor/annotation/throttling.go Refactored throttling annotation logic from ingestlimits
pkg/distributor/annotation/sampling.go New sampling annotation creation logic
pkg/distributor/model/push.go Updates to use new annotation package and adds MarkSampledRequest method
pkg/distributor/distributor.go Modified sampling logic to track and annotate sampling sources
pkg/distributor/model/push_test.go Updated test references to new annotation constants
pkg/distributor/distributor_test.go Updated test expectations for new sampling.Source return type

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

PeriodLimitMb int `json:"periodLimitMb"`
LimitResetTime int64 `json:"limitResetTime"`
SamplingPeriodSec int `json:"samplingPeriodSec"`
SamplingRequests int `yaml:"samplingRequests"`
Copy link
Preview

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

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

The struct tag should be json:"samplingRequests" instead of yaml:"samplingRequests" to match the other fields in this JSON-serialized struct.

Suggested change
SamplingRequests int `yaml:"samplingRequests"`
SamplingRequests int `json:"samplingRequests"`

Copilot uses AI. Check for mistakes.

@aleks-p aleks-p merged commit 214733c into main Aug 15, 2025
24 checks passed
@aleks-p aleks-p deleted the feat/annotate-sampled-profiles branch August 15, 2025 12:29
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.

2 participants