Skip to content

Avoid metrics persistence setup for in-memory event buffering#4877

Open
mj006648 wants to merge 2 commits into
apache:mainfrom
mj006648:feature/issue-4594-inmemory-metrics
Open

Avoid metrics persistence setup for in-memory event buffering#4877
mj006648 wants to merge 2 commits into
apache:mainfrom
mj006648:feature/issue-4594-inmemory-metrics

Conversation

@mj006648

Copy link
Copy Markdown
Contributor

Summary

Fixes #4594.

This avoids creating MetricsPersistence for InMemoryBufferEventListener. The listener only needs to write buffered event entities, so it now passes a no-op MetricsPersistence into PolarisCallContext instead of asking the MetaStoreManagerFactory to create one.

The focused buffer-size test now verifies that flushing events does not request metrics persistence.

Tests

Checklist

@mj006648 mj006648 force-pushed the feature/issue-4594-inmemory-metrics branch from a320d4a to 35dc590 Compare June 24, 2026 06:36
@mj006648 mj006648 marked this pull request as ready for review June 24, 2026 07:05
dimas-b
dimas-b previously approved these changes Jun 24, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix, @mj006648 ! LGTM 👍

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jun 24, 2026
@dimas-b

dimas-b commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Planning to merge on Jun 26

var metricsPersistence = metaStoreManagerFactory.getOrCreateMetricsPersistence(realmContext);
var callContext = new PolarisCallContext(realmContext, basePersistence, metricsPersistence);
var callContext =
new PolarisCallContext(realmContext, basePersistence, NO_OP_METRICS_PERSISTENCE);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hmmm, I feel the right fix should be undo the metric persistence being part of the polaris call context param. But not sure if that's gonna affecting Anand's ongoing work

If we want a quick fix, wonder if the arg takes null value? I'm inclined this approach as it does not introduce the MetricsPersistence class dependency, which its class path will be changed for sure.

@dimas-b dimas-b Jun 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAIK, the impact on @obelix74 's work is going to be minimal (bearable).

@obelix74 : Please comment if you have a concern.

var metricsPersistence = metaStoreManagerFactory.getOrCreateMetricsPersistence(realmContext);
var callContext = new PolarisCallContext(realmContext, basePersistence, metricsPersistence);
var callContext =
new PolarisCallContext(realmContext, basePersistence, NO_OP_METRICS_PERSISTENCE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is a side effect of separating metricsPersistence, which forces PolarisCallContext to carry more xxxPersistence that is not needed. I don't like that direction, but since we are here. I'd create a new PolarisCallContext constructor to avoid something like NO_OP_METRICS_PERSISTENCE. If u look at the class, we actually have that constructor. Maybe we just need to remove the depreaction annotation.

Move the no-op fallback behind PolarisCallContext so the in-memory listener only needs BasePersistence.

Constraint: Review feedback asked to avoid listener-local MetricsPersistence

Confidence: high

Scope-risk: narrow

Tested: targeted listener test; format compileAll

Not-tested: runtime-service:check hits pre-existing NoSQL/InMem bootstrap failure locally
@mj006648

Copy link
Copy Markdown
Contributor Author

Thanks @flyrain and @flyingImer for the pointers.

I updated this to remove the MetricsPersistence dependency from InMemoryBufferEventListener. The listener now just passes the BasePersistence it already needs, and the fallback stays inside PolarisCallContext through the convenience constructor.

CI is green now.

@dimas-b dimas-b requested review from flyingImer and flyrain June 26, 2026 15:09

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 Thanks @mj006648 for the change.

@dimas-b

dimas-b commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@mj006648 : sorry to cause conflicts here... Could you rebase, please?

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.

Do not instantiate MetricsPersistence for InMemoryBufferEventListener

5 participants