Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix escaping#1668

Merged
zeitlinger merged 2 commits intomainprometheus/client_java:mainfrom
fix-escapingprometheus/client_java:fix-escapingCopy head branch name to clipboard
Nov 7, 2025
Merged

Fix escaping#1668
zeitlinger merged 2 commits intomainprometheus/client_java:mainfrom
fix-escapingprometheus/client_java:fix-escapingCopy head branch name to clipboard

Conversation

@zeitlinger
Copy link
Member

Fixes #1666

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger requested a review from Copilot November 7, 2025 17:56
@zeitlinger zeitlinger self-assigned this Nov 7, 2025
@zeitlinger zeitlinger requested a review from jaydeluca November 7, 2025 17:56
Copy link
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 handling of metric names containing characters that are not valid in legacy Prometheus naming conventions (e.g., colons and dots). The changes ensure that when such names are encountered, they are properly escaped and formatted according to OpenMetrics and Prometheus text format specifications.

Key changes:

  • Corrected the validation check in PrometheusTextFormatWriter from isValidLegacyLabelName to isValidLegacyMetricName
  • Fixed the comma separator logic in TextFormatUtil.writeLabels to handle cases where metric names are inside braces
  • Added test cases for metrics with colons and dots in their names
  • Updated existing test expectations to use colons in metric names for validation

Reviewed Changes

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

File Description
PrometheusTextFormatWriter.java Fixed bug where metric name validation was incorrectly using label name validation method
TextFormatUtil.java Fixed comma separator logic to account for metric names inside braces when adding additional labels
ExpositionFormatsTest.java Added test case for histogram with dots in name and updated existing counter test to use colons

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zeitlinger zeitlinger merged commit 748b190 into main Nov 7, 2025
41 checks passed
@zeitlinger zeitlinger deleted the fix-escaping branch November 7, 2025 18:56
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.

Unexpected text output of metric name containing : and broken histogram name output

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.