-
Notifications
You must be signed in to change notification settings - Fork 460
Inject MetricsPersistence directly into PersistingMetricsReporter #4708
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| package org.apache.polaris.core.persistence.metrics; | ||
|
|
||
| import org.apache.polaris.core.PolarisCallContext; | ||
| import org.apache.polaris.core.persistence.BasePersistence; | ||
| import org.jspecify.annotations.NonNull; | ||
|
|
||
| /** | ||
|
|
@@ -56,7 +57,10 @@ public interface PolarisMetricsManager { | |
| */ | ||
| default void writeScanMetrics( | ||
| @NonNull PolarisCallContext callCtx, @NonNull ScanMetricsRecord record) { | ||
| callCtx.getMetricsPersistence().writeScanReport(record); | ||
| BasePersistence metaStore = callCtx.getMetaStore(); | ||
| if (metaStore instanceof MetricsPersistence metricsPersistence) { | ||
| metricsPersistence.writeScanReport(record); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -73,6 +77,9 @@ default void writeScanMetrics( | |
| */ | ||
| default void writeCommitMetrics( | ||
| @NonNull PolarisCallContext callCtx, @NonNull CommitMetricsRecord record) { | ||
| callCtx.getMetricsPersistence().writeCommitReport(record); | ||
| BasePersistence metaStore = callCtx.getMetaStore(); | ||
| if (metaStore instanceof MetricsPersistence metricsPersistence) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also not invoked, AFAIK. |
||
| metricsPersistence.writeCommitReport(record); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,13 +140,19 @@ public CallContext polarisCallContext( | |
| RealmConfigurationSource configurationSource, | ||
| MetaStoreManagerFactory metaStoreManagerFactory) { | ||
| BasePersistence metaStore = metaStoreManagerFactory.getOrCreateSession(realmContext); | ||
| return new PolarisCallContext(realmContext, metaStore, configurationSource); | ||
| } | ||
|
|
||
| @Produces | ||
| @RequestScoped | ||
| public MetricsPersistence metricsPersistence( | ||
| RealmContext realmContext, MetaStoreManagerFactory metaStoreManagerFactory) { | ||
| BasePersistence metaStore = metaStoreManagerFactory.getOrCreateSession(realmContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why bother calling The old optimization of reusing the same object is no longer relevant. I think calling |
||
| // When the backend implements both SPIs on the same instance (e.g. JDBC, in-memory), reuse the | ||
| // session instead of building a second persistence instance per request. | ||
| MetricsPersistence metricsPersistence = | ||
| (metaStore instanceof MetricsPersistence mp) | ||
| ? mp | ||
| : metaStoreManagerFactory.getOrCreateMetricsPersistence(realmContext); | ||
| return new PolarisCallContext(realmContext, metaStore, metricsPersistence, configurationSource); | ||
| return (metaStore instanceof MetricsPersistence mp) | ||
| ? mp | ||
| : metaStoreManagerFactory.getOrCreateMetricsPersistence(realmContext); | ||
| } | ||
|
|
||
| @Produces | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is no longer invoked, I think... why not remove it?