8000 PROM-39: implement type and unit labels for PRW 2.0 by dashpole · Pull Request #16774 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PROM-39: implement type and unit labels for PRW 2.0 #16774

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

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

Conversation

dashpole
Copy link
Contributor

Part of #16610

This implements the type and unit labels feature for the 2.0 handler.

cc @ArthurSens @bwplotka @aknuds1 @carrieedwards

Type: modelMd.Type,
Unit: modelMd.Unit,
}
m.SetToLabels(builder)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to find a way to add these to the ScratchBuilder we create above, but the ts.ToLabels function resets and then returns the completed labels. Let me know if making a new builder to add these two labels is likely to be too expensive, and I can try to explore modifying ToLabels, or adding a new function somewhere to desymbolize and also add type and unit labels.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the overhead cost is of creating the second builder is, but probably enough that we want to avoid doing it on every iteration when this feature flag is set.

Modifying ToLabels in write/v2/codec.go seems reasonable, or adding a ToLabelsWithMetadata there as well.

Copy link
Member

Choose a reason for hiding this comment

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

Absolutely change the codec, it's ours and it can be expanded 👍🏽

Copy link
Member

Choose a reason for hiding this comment

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

I was initially thinking about NOT reseting and renaming our methods to AddToLabels etc, but there's a challenge -- we need to ensure NO duplicates and priority over metadata values for type and unit labels.

Thus, I would just add desymbolizeLabelsWithMetadata priv func indeed that will do this and perhaps ToLabels(b, symbols, metaAware bool), ToLabelsWithMetadata or ToLabelsMetaAware(...) indeed. I would vote for the bool inside existing method so it's very clear for every new use of this PRW2 that you can make this decision of adding those new labels or not, otherwise it's less discoverable/known if ToLabels handles that or not

WDYT?

10000 Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added "AddToLabels" to allow me to re-use the builder. Seems to align with other similar functions, and prevents the writev2 package from depending on the metadata package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bwplotka can you clarify? Should user labels take precedence over labels from metadata? I can just change the ordering.

Copy link
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 good, just the codec improvements as we discussed and perhaps some consistency on the feature fields 👍🏽

Type: modelMd.Type,
Unit: modelMd.Unit,
}
m.SetToLabels(builder)
Copy link
Member

Choose a reason for hiding this comment

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

I was initially thinking about NOT reseting and renaming our methods to AddToLabels etc, but there's a challenge -- we need to ensure NO duplicates and priority over metadata values for type and unit labels.

Thus, I would just add desymbolizeLabelsWithMetadata priv func indeed that will do this and perhaps ToLabels(b, symbols, metaAware bool), ToLabelsWithMetadata or ToLabelsMetaAware(...) indeed. I would vote for the bool inside existing method so it's very clear for every new use of this PRW2 that you can make this decision of adding those new labels or not, otherwise it's less discoverable/known if ToLabels handles that or not

WDYT?

Signed-off-by: David Ashpole <dashpole@google.com>
dashpole added 2 commits June 27, 2025 14:33
Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
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.

3 participants
0