Skip to content

remote-write: Add type and unit labels to receiver when feature flag enabled#17329

Merged
bwplotka merged 7 commits intoprometheus:mainfrom
hxrshxz:type-and-unit-labels
Oct 15, 2025
Merged

remote-write: Add type and unit labels to receiver when feature flag enabled#17329
bwplotka merged 7 commits intoprometheus:mainfrom
hxrshxz:type-and-unit-labels

Conversation

@hxrshxz
Copy link
Copy Markdown
Contributor

@hxrshxz hxrshxz commented Oct 12, 2025

Which issue(s) does the PR fix:

Fixes #17319

Does this PR introduce a user-facing change?

[FEATURE] Remote-write: Type and unit labels are now correctly propagated to the Prometheus receiver when using Remote Write v2 with the `type-and-unit-labels` feature flag enabled.

@hxrshxz hxrshxz requested review from Copilot and removed request for Copilot October 12, 2025 17:54
@hxrshxz hxrshxz force-pushed the type-and-unit-labels branch from 78364cf to 0f98c24 Compare October 12, 2025 18:02
Copilot AI review requested due to automatic review settings October 12, 2025 18:42
Copy link
Copy Markdown
Contributor

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 fixes a bug where type and unit labels were not being propagated to the Prometheus receiver when using Remote Write v2 with the type-and-unit-labels feature flag enabled. The fix adds the feature flag parameter to the write handler constructor and implements logic to add __type__ and __unit__ labels from metadata when the flag is enabled.

  • Passes the enableTypeAndUnitLabels parameter to the remote write handler constructor
  • Adds logic to extract type and unit metadata and convert them to labels in Remote Write v2 processing
  • Includes comprehensive test coverage for various scenarios with and without the feature flag

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
web/api/v1/api.go Passes the enableTypeAndUnitLabels parameter to NewWriteHandler
storage/remote/write_handler.go Adds feature flag field and implements type/unit label addition logic
storage/remote/write_handler_test.go Updates all test calls to include the new parameter
storage/remote/write_handler_type_unit_test.go Adds comprehensive test coverage for the new functionality

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

Signed-off-by: Harsh <[email protected]>
@hxrshxz hxrshxz force-pushed the type-and-unit-labels branch from 54c2a0b to 11035f6 Compare October 12, 2025 19:17
Signed-off-by: Harsh <[email protected]>
Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

Left some comments, let me know if those make sense! Generally looks good, just a few pointers around code sustainability and reliability of tests.

Also, do you mind changing [BUGFIX] in PR description to [FEATURE]? This is not a bug just an iterative implementation.

hxrshxz and others added 3 commits October 14, 2025 00:39
Co-authored-by: Bartlomiej Plotka <[email protected]>
Signed-off-by: harsh kumar <[email protected]>
Co-authored-by: Bartlomiej Plotka <[email protected]>
Signed-off-by: harsh kumar <[email protected]>
@hxrshxz hxrshxz force-pushed the type-and-unit-labels branch from 62433a1 to cb47b6b Compare October 13, 2025 19:17
@hxrshxz hxrshxz requested a review from bwplotka October 14, 2025 06:53
Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Looks great! LGTM, just another suggestion to make things much more efficient.

@hxrshxz
Copy link
Copy Markdown
Contributor Author

hxrshxz commented Oct 15, 2025

@bwplotka I agree this adds some overhead Maybe we can merge this with the TODO for now and optimize ts.ToLabels() in a follow up. If that sounds good then I can raise a new issue for this and make the changes there?

@hxrshxz hxrshxz requested a review from bwplotka October 15, 2025 17:16
@bwplotka
Copy link
Copy Markdown
Member

👍🏽

@bwplotka bwplotka merged commit 16a9a82 into prometheus:main Oct 15, 2025
28 checks passed
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.

[RW2] Type and unit labels not propagated to Prometheus receiver

3 participants