Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
af07d42
feat(metrics): Add MetricsPersistence SPI for backend-agnostic metric…
Jan 29, 2026
bceb136
refactor(metrics): Remove ambient context fields from SPI records
Jan 29, 2026
01d8e93
refactor(metrics): Replace offset-based pagination with PageToken pat…
Jan 31, 2026
59c907f
Review comments
Feb 4, 2026
9ec22ea
Review comments
Feb 4, 2026
b66a0d6
refactor: Remove TableIdentifier and catalogName from SPI records
Feb 4, 2026
7ac814e
refactor: Use List<String> for namespace instead of dot-separated string
Feb 4, 2026
4a3bc9f
refactor: Use tableId instead of tableName in metrics records
Feb 4, 2026
7d4212c
refactor: Remove namespace from MetricsQueryCriteria
Feb 5, 2026
9ac1f46
Add schema-v4.sql for metrics tables (#3337)
Jan 24, 2026
de341e6
Merged main
Jan 27, 2026
9260dda
refactor: Update metrics schema to match SPI changes
Feb 4, 2026
472f6f3
refactor: Change table_name to table_id in metrics schema
Feb 4, 2026
b7925c8
feat(events): Enable metrics event emission in reportMetrics()
Jan 17, 2026
6d5f2aa
feat(events): Add metrics persistence handler for AFTER_REPORT_METRIC…
Jan 17, 2026
850b3d1
feat(persistence): Add database schema and model classes for metrics …
Jan 17, 2026
58563e0
feat(persistence): Add JDBC persistence implementation for metrics (P…
Jan 17, 2026
86fe3d7
feat(reporting): Add metrics reporters infrastructure (PR#5)
Jan 17, 2026
0a0ffdc
feat(cleanup): Add metrics cleanup service and documentation (PR#6)
Jan 17, 2026
3507365
test(integration): Update InMemoryBufferEventListenerIntegrationTest …
Jan 17, 2026
f73903a
Fix failing InMemoryBufferEventListenerIntegrationTest by enabling EN…
Jan 17, 2026
5785fad
feat: Add backward-compatible metrics processing system
Jan 19, 2026
b86f670
refactor: Replace event-based metrics with MetricsProcessor interface
Jan 19, 2026
1488c35
Removed internal document
Jan 19, 2026
17456d6
docs: Update CHANGELOG for metrics processor configuration
Jan 19, 2026
95d5e2f
SpotlessApply
Jan 19, 2026
3c17861
Review comments
Jan 19, 2026
e685f40
Review comments
Jan 19, 2026
bf934a0
Added a service producer for SpanContext
Jan 20, 2026
266fa7e
Review comments.
Jan 20, 2026
da125d8
refactor: Remove PR2 files (MetricsProcessor framework) from PR1 branch
Jan 21, 2026
f57ad41
Add schema version checks to metrics persistence methods
Jan 21, 2026
df0d46f
Apply spotless formatting
Jan 21, 2026
7715acf
Add tests for schema version < 4 graceful degradation
Jan 23, 2026
e857bbe
Remove query indexes, keep only retention cleanup index
Jan 23, 2026
efe31c2
Add realm_id to PRIMARY KEY and roles junction tables
Jan 23, 2026
1de8bd4
Fix code review issues: transaction support, role validation, and rol…
Jan 23, 2026
53145ea
Integrate MetricsPersistence SPI with JDBC implementation
Feb 4, 2026
2be4d9d
Add unit tests for SpiModelConverter
Feb 4, 2026
a6a67f0
fix: Replace AttributeMap with EventAttributeMap and apply spotless f…
Feb 4, 2026
fd45762
feat: Add PersistingMetricsReporter to connect REST API to MetricsPer…
Feb 4, 2026
3e4b300
test: Add unit tests for PersistingMetricsReporter
Feb 4, 2026
a438cd7
fix: Restore eventAttributeMap for proper TABLE_METADATA event handling
Feb 4, 2026
a2c9f5e
refactor: Update JDBC layer to match SPI changes
Feb 4, 2026
c571d29
refactor: Update JDBC layer to use tableId instead of tableName
Feb 4, 2026
113aae2
fix: Apply tableId schema changes and update tests
Feb 4, 2026
516af0a
refactor: Remove namespace from JDBC query methods
Feb 5, 2026
f7e5e45
fix: Update PersistingMetricsReporter to use tableId and namespace API
Feb 5, 2026
d6b4734
fix: Update PersistingMetricsReporterTest for new tableId/namespace API
Feb 5, 2026
ba3668b
fix: address code review correctness issues
Feb 5, 2026
65e8cb4
feat: Add separate metrics schema with --include-metrics bootstrap op…
Feb 5, 2026
fe2a7ed
chore: Sync with feat-3337-metrics-persistence-spi and feat-3337-sche…
Feb 5, 2026
3eb9912
refactor: Denormalize principal roles into JSON array column
Feb 6, 2026
f84d2b5
Merge feat-3337-schema-v4: Denormalize principal roles into JSON array
Feb 6, 2026
41bb810
refactor: Remove metrics event types
Feb 6, 2026
5d831cd
refactor: Decouple MetricsPersistence from MetaStoreManagerFactory
Feb 6, 2026
2f46564
test: Add unit tests for principal_role_ids in metrics report models
Feb 6, 2026
4dece9e
style: Apply spotless formatting
Feb 6, 2026
68fed86
test: Add tests for --include-metrics bootstrap option
Feb 6, 2026
eabdd15
refactor: Remove schema-v4 version fixes (moved to separate PR)
Feb 6, 2026
86789d7
refactor: Remove principal_role_ids from metrics schema
Feb 6, 2026
714b614
refactor: Remove principal_role_ids from model classes and tests
Feb 6, 2026
4d0d395
refactor: Move metrics methods to JdbcMetricsPersistence and wire to CDI
Feb 6, 2026
ebb5bc8
refactor: Remove namespace from JDBC metrics implementation
Feb 6, 2026
b2396da
Fix failing tests
Feb 6, 2026
2328824
refactor: Address PR review comments for MetricsPersistence
Feb 6, 2026
c23b162
feat: Implement separate MetricsSchemaBootstrap SPI handler
Feb 7, 2026
4e1a2a6
Add unit tests for BootstrapMetricsCommand
Feb 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ venv
# to override default properties for local development.
# And then use `./gradlew run -Dquarkus.profile=local` to run Polaris with dev profile.
application-local.properties
.polaris-work-notes.md
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti

### Breaking changes

- The (Before/After)CommitViewEvent has been removed.
- The (Before/After)CommitTableEvent has been removed.
- The `PolarisMetricsReporter.reportMetric()` method signature has been extended to include a `receivedTimestamp` parameter of type `java.time.Instant`.

Expand Down
10 changes: 10 additions & 0 deletions persistence/relational-jdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ dependencies {

compileOnly(platform(libs.jackson.bom))
compileOnly("com.fasterxml.jackson.core:jackson-annotations")
compileOnly("com.fasterxml.jackson.core:jackson-databind")
compileOnly(libs.jakarta.annotation.api)
compileOnly(libs.jakarta.enterprise.cdi.api)
compileOnly(libs.jakarta.inject.api)

// Iceberg API for metrics report conversion
compileOnly(platform(libs.iceberg.bom))
compileOnly("org.apache.iceberg:iceberg-api")
compileOnly("org.apache.iceberg:iceberg-core")

implementation(libs.smallrye.common.annotation) // @Identifier
implementation(libs.postgresql)

Expand All @@ -43,6 +49,10 @@ dependencies {
testImplementation(libs.h2)
testImplementation(testFixtures(project(":polaris-core")))

// Iceberg API for SpiModelConverter tests
testImplementation(platform(libs.iceberg.bom))
testImplementation("org.apache.iceberg:iceberg-api")

testImplementation(platform(libs.testcontainers.bom))

testImplementation("org.testcontainers:testcontainers-junit-jupiter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,24 @@ public InputStream openInitScriptResource(int schemaVersion) {
ClassLoader classLoader = DatasourceOperations.class.getClassLoader();
return classLoader.getResourceAsStream(resourceName);
}

/**
* Open an InputStream that contains data from the metrics schema init script. This stream should
* be closed by the caller.
*
* @param metricsSchemaVersion the metrics schema version (currently only 1 is supported)
* @return an InputStream for the metrics schema SQL file
*/
public InputStream openMetricsSchemaResource(int metricsSchemaVersion) {
if (metricsSchemaVersion != 1) {
throw new IllegalArgumentException(
"Unknown or invalid metrics schema version " + metricsSchemaVersion);
}

final String resourceName =
String.format("%s/schema-metrics-v%d.sql", this.getDisplayName(), metricsSchemaVersion);

ClassLoader classLoader = DatasourceOperations.class.getClassLoader();
return classLoader.getResourceAsStream(resourceName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,18 @@ public static int getRequestedSchemaVersion(BootstrapOptions bootstrapOptions) {
}
return -1;
}

/**
* Determines whether the metrics schema should be included during bootstrap.
*
* @param bootstrapOptions The bootstrap options containing schema information.
* @return true if the metrics schema should be included, false otherwise.
*/
public static boolean shouldIncludeMetrics(BootstrapOptions bootstrapOptions) {
SchemaOptions schemaOptions = bootstrapOptions.schemaOptions();
if (schemaOptions != null) {
return schemaOptions.includeMetrics();
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.polaris.core.persistence.cache.InMemoryEntityCache;
import org.apache.polaris.core.persistence.dao.entity.BaseResult;
import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
import org.apache.polaris.core.persistence.metrics.MetricsSchemaBootstrap;
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -78,6 +79,10 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory {
@Inject RelationalJdbcConfiguration relationalJdbcConfiguration;
@Inject RealmConfig realmConfig;

@Inject
@Identifier("relational-jdbc")
MetricsSchemaBootstrap metricsSchemaBootstrap;

protected JdbcMetaStoreManagerFactory() {}

protected PrincipalSecretsGenerator secretsGenerator(
Expand Down Expand Up @@ -172,6 +177,11 @@ public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
datasourceOperations
.getDatabaseType()
.openInitScriptResource(effectiveSchemaVersion));

// Run the metrics schema bootstrap if requested
if (JdbcBootstrapUtils.shouldIncludeMetrics(bootstrapOptions)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to sync up and not forget: I believe it would be nice to have a separate bootstrap handler for the metrics schema, but that can be done as a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented in commit c23b162e5. Created a MetricsSchemaBootstrap SPI interface in polaris-core with bootstrap(realmId) and isBootstrapped(realmId) methods, plus a NOOP constant. The JDBC implementation (JdbcMetricsSchemaBootstrap) is idempotent and uses the metrics_version table to track bootstrap state.

Also added a new bootstrap-metrics CLI command that allows operators to bootstrap the metrics schema independently:

polaris-admin bootstrap-metrics -r my-realm

This enables adding metrics persistence support to existing deployments without re-bootstrapping the entity schema.

metricsSchemaBootstrap.bootstrap(realm);
}
} catch (SQLException e) {
throw new RuntimeException(
String.format("Error executing sql script: %s", e.getMessage()), e);
Expand Down
Loading