Skip to content

Conversation

@gensericghiro
Copy link
Contributor

@gensericghiro gensericghiro commented Nov 13, 2025

Summary

When working on
KIP-1091,
we mistakenly applied the process-id tag to all client-level metrics,
rather than just the client-state, thread-state, and
recording-level metrics as specified in the KIP. This issue came to
light while working on KIP-1221, which aimed to add the application-id
as a tag to the client-state metric introduced by KIP-1091. This PR
removes these tags from all metrics by default, and adds them to only
the client-state (application-id + process-id) and the
recording-level (process-id only)

Tests

Unit tests in ClientMetricsTest.java and StreamsMetricsImplTest.java

@github-actions github-actions bot added triage PRs from the community streams labels Nov 13, 2025
Copy link
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

@gensericghiro thanks for the PR - I've made an initial pass

mkEntry("client-id", CLIENT_ID)
)
);
assertThat(metrics.metric(name), notNullValue());
Copy link
Member

Choose a reason for hiding this comment

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

Why just not null vs. asserting the name is equal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, but I was being consistent with what's here. I can change both

Copy link
Member

Choose a reason for hiding this comment

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

Let's change the other code, too. It's a little weird to not check the name (or is there some non-deterministic naming, like a "thread name" which could mess with us?)

mkEntry("additional-tag", "additional-value")
)
);
assertThat(metrics.metric(name), notNullValue());
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@mjsax mjsax added ci-approved and removed triage PRs from the community labels Nov 14, 2025
final RecordingLevel recordingLevel,
final T value) {
final MetricName metricName = metrics.metricName(name, CLIENT_LEVEL_GROUP, description,
clientLevelTagMap(additionalTags));
Copy link
Member

Choose a reason for hiding this comment

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

nit: Formatting. Why the line break? Should just go to above line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we not enforce a max 100 width on columns? It makes the code hard to read otherwise

Copy link
Member

Choose a reason for hiding this comment

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

No that I know of (and 100 would be very tight). As long as checkstyle does not complain, we are good.

The other point is: if we really have too many parameter, the current formatting with a single line break is also very hard to read, and if we thing the line gets to long, we should go with a single-parameter per line formatting:

final MetricName metricName = metrics.metricName(
    name,
    CLIENT_LEVEL_GROUP,
    description,
    clientLevelTagMap(additionalTags)
);

final RecordingLevel recordingLevel,
final Gauge<T> valueProvider) {
final MetricName metricName = metrics.metricName(name, CLIENT_LEVEL_GROUP, description,
clientLevelTagMap(additionalTags));
Copy link
Member

Choose a reason for hiding this comment

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

as above

final RecordingLevel recordingLevel = RecordingLevel.INFO;
setupGetNewSensorTest(metrics);
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, PROCESS_ID, APPLICATION_ID,
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID,
Copy link
Member

Choose a reason for hiding this comment

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

nit: formatting. Let's move time parameter into this line, too, for some cleanup (same below)

mkEntry("client-id", CLIENT_ID)
)
);
assertThat(metrics.metric(name), notNullValue());
Copy link
Member

Choose a reason for hiding this comment

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

Same question as Bill asks further below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, but I was being consistent with what's here. I can change both

mkEntry("additional-tag", "additional-value")
)
);
assertThat(metrics.metric(name), notNullValue());
Copy link
Member

Choose a reason for hiding this comment

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

Same

public void shouldRemoveClientLevelMetricsAndSensors() {
final Metrics metrics = mock(Metrics.class);
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, PROCESS_ID, APPLICATION_ID,
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID,
Copy link
Member

@mjsax mjsax Nov 14, 2025

Choose a reason for hiding this comment

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

Nit: more formatting cleanup in this file, too :)

Copy link
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Couple of nits.

@AndrewJSchofield
Copy link
Member

@gensericghiro Please fix the check style failure in the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants