feat: OM2 writer outputs names as provided, no suffix appending#1957
Open
zeitlinger wants to merge 1 commit intomainfrom
Open
feat: OM2 writer outputs names as provided, no suffix appending#1957zeitlinger wants to merge 1 commit intomainfrom
zeitlinger wants to merge 1 commit intomainfrom
Conversation
7 tasks
8a18993 to
23a0eb4
Compare
23a0eb4 to
9fb30c8
Compare
The OM2 writer now uses expositionBaseName instead of appending _total (counters) or unit suffixes. The _info suffix is enforced per the OM2 spec (MUST). Tests updated to verify OM2-specific output rather than asserting identity with OM1. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
9fb30c8 to
d1b0517
Compare
jaydeluca
reviewed
Mar 20, 2026
| + "my_counter 42.0\n" | ||
| + "my_counter_created 1672850385.800\n" | ||
| + "# EOF\n"); | ||
| } |
Collaborator
There was a problem hiding this comment.
how should info metrics work?
if we add a test:
@Test
void testInfoMetricEnforcesInfoSuffix() throws IOException {
// User provides "jvm" → OM2 outputs "jvm_info"
MetricSnapshots snapshots = MetricSnapshots.of(
InfoSnapshot.builder().name("jvm").help("JVM info")
.dataPoint(InfoSnapshot.InfoDataPointSnapshot.builder().build()).build());
String om2Output = writeWithOM2(snapshots);
// is this right?
assertThat(om2Output).contains("# TYPE jvm info");
assertThat(om2Output).contains("jvm_info 1");
}the result is:
# TYPE jvm info
# HELP jvm JVM info
jvm_info 1
# EOF
The writeInfo method enforces _info suffix, then removes it for the TYPE line, and then writes the time series with the full _info suffix
Do we require the TYPE line to use the base name or the full name?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OM2 writer now uses
expositionBaseNamedirectly instead ofappending
_total(counters) or unit suffixes. The_infosuffixis enforced per the OM2 spec (MUST). Part of #1942.
Key table
Counter("events")events_totaleventsCounter("events_total")events_totalevents_totalCounter("req").unit(BYTES)req_bytes_totalreq_bytesCounter("req_bytes").unit(BYTES)req_bytes_totalreq_bytesGauge("events_total")events_totalevents_totalInfo("target")target_infotarget_infoPR stack
preserve_names(independent)Test plan
mise run compilepasses_total/unit suffix appending_infosuffix enforcement testedPart of #1912.