-
Notifications
You must be signed in to change notification settings - Fork 461
(feat) Implement metrics rest api #4115
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
Open
obelix74
wants to merge
30
commits into
apache:main
Choose a base branch
from
obelix74:implement_metrics_rest_api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ab99206
feat(metrics): implement Table Metrics REST API
f9345c2
docs: add changelog and documentation for Table Metrics REST API
2106b0f
feat(metrics): adopt stable envelope design for metrics reports API
d21c8e5
fix(metrics): harden error handling and test coverage in MetricsRepor…
699405f
fix(metrics): remove internal catalogId/tableId from metrics report r…
2a7039a
refactor(metrics): remove AtomicReference and columns param per revie…
83f2292
Spotless fixes
0a2d009
refactor(metrics): address PR review comments
e6b75c2
docs(metrics): mark Metrics Reports API as beta in changelog and spec
94bece7
fix(metrics): add resteasy-reactive testRuntimeOnly to fix ClassNotFo…
ea89998
fix(metrics): add @Beta to PolarisMetricsManager and PolarisMetricsRe…
a0ffa8b
Review comments.
756bf49
Replace Map<String,Object> response with typed Jackson record classes
66bfedc
fix(jdbc): replace unresolved @Nonnull with @NonNull in JdbcBasePersi…
0800631
fix(metrics-api): use JSON arrays for projectedFieldIds/Names, add #4…
a0a4f62
fix(bom): add polaris-api-metrics-reports-service to BOM
f370e93
ci: retrigger CI (transient RH registry 500 on minio job)
8f5ae68
refactor(metrics): fix SPI layering — move IcebergMetricsReporter to …
4119788
fix(metrics): restore MetricsPersistence SPI types to polaris-core
86ee037
fix(metrics): remove MetricsPersistence from JdbcBasePersistenceImpl,…
e904d25
fix(metrics): rename lambda params to avoid shadowing createHandler's…
474c039
fix(metrics): fix three runtime failures from Scope 1 refactor
9d336c8
fix(metrics): use 'default' identifier for LoggingMetricsReporter to …
4702adf
docs(config): regenerate config reference for metrics reporting default
286adc6
refactor(metrics): move IcebergMetricsReporter SPI to extensions/metr…
48816e4
fix(metrics): use runtimeOnly for metrics-reports impl dep in runtime…
c8a050c
fix(metrics): remove metrics-reports impl dep from runtime/service
8a779cc
refactor(metrics): move NoOpMetricsReporter to SPI; address review co…
f611188
refactor(metrics): address PR #4115 review comments
cc33a7f
refactor(metrics): address PR review comments r3424416195, r342442294…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import org.openapitools.generator.gradle.plugin.tasks.GenerateTask | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.openapi.generator) | ||
| id("polaris-client") | ||
| id("org.kordamp.gradle.jandex") | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(project(":polaris-core")) | ||
|
|
||
| compileOnly(platform(libs.jackson.bom)) | ||
| compileOnly("com.fasterxml.jackson.core:jackson-annotations") | ||
|
|
||
| compileOnly(libs.jakarta.annotation.api) | ||
| compileOnly(libs.jakarta.inject.api) | ||
| compileOnly(libs.jakarta.validation.api) | ||
| compileOnly(libs.microprofile.fault.tolerance.api) | ||
| compileOnly(libs.swagger.annotations) | ||
|
|
||
| implementation(libs.jakarta.servlet.api) | ||
| implementation(libs.jakarta.ws.rs.api) | ||
|
|
||
| compileOnly(platform(libs.micrometer.bom)) | ||
| compileOnly("io.micrometer:micrometer-core") | ||
|
|
||
| implementation(libs.slf4j.api) | ||
| } | ||
|
|
||
| val rootDir = rootProject.layout.projectDirectory | ||
| val specsDir = rootDir.dir("spec") | ||
| val templatesDir = rootDir.dir("server-templates") | ||
| val generatedDir = project.layout.buildDirectory.dir("generated-openapi") | ||
| val generatedOpenApiSrcDir = project.layout.buildDirectory.dir("generated-openapi/src/main/java") | ||
|
|
||
| openApiGenerate { | ||
| inputSpec = provider { specsDir.file("metrics-reports-service.yml").asFile.absolutePath } | ||
| generatorName = "jaxrs-resteasy" | ||
| outputDir = provider { generatedDir.get().asFile.absolutePath } | ||
| apiPackage = "org.apache.polaris.service.metrics.api" | ||
| modelPackage = "org.apache.polaris.core.metrics.api.model" | ||
| ignoreFileOverride.set(provider { rootDir.file(".openapi-generator-ignore").asFile.absolutePath }) | ||
| removeOperationIdPrefix.set(true) | ||
| templateDir.set(provider { templatesDir.asFile.absolutePath }) | ||
| globalProperties.put("apis", "") | ||
| globalProperties.put("models", "") | ||
| globalProperties.put("apiDocs", "false") | ||
| globalProperties.put("modelTests", "false") | ||
| configOptions.put("openApiNullable", "false") | ||
| configOptions.put("useBeanValidation", "true") | ||
| configOptions.put("sourceFolder", "src/main/java") | ||
| configOptions.put("useJakartaEe", "true") | ||
| configOptions.put("generateBuilders", "true") | ||
| configOptions.put("generateConstructorWithAllArgs", "true") | ||
| configOptions.put("hideGenerationTimestamp", "true") | ||
| additionalProperties.put("apiNamePrefix", "Polaris") | ||
| additionalProperties.put("apiNameSuffix", "Api") | ||
| additionalProperties.put("metricsPrefix", "polaris") | ||
| serverVariables.put("basePath", "api/metrics-reports/v1") | ||
| } | ||
|
|
||
| listOf("sourcesJar", "compileJava", "processResources").forEach { task -> | ||
| tasks.named(task) { dependsOn("openApiGenerate") } | ||
| } | ||
|
|
||
| sourceSets { main { java { srcDir(generatedOpenApiSrcDir) } } } | ||
|
|
||
| tasks.named<GenerateTask>("openApiGenerate") { | ||
| inputs.dir(templatesDir) | ||
| inputs.dir(specsDir) | ||
| actions.addFirst { delete { delete(generatedDir) } } | ||
| } | ||
|
|
||
| tasks.named("javadoc") { dependsOn("jandex") } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| id("polaris-server") | ||
| id("org.kordamp.gradle.jandex") | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(project(":polaris-extensions-metrics-reports-spi")) | ||
|
|
||
| implementation(platform(libs.iceberg.bom)) | ||
| implementation("org.apache.iceberg:iceberg-api") | ||
|
|
||
| implementation(libs.jakarta.enterprise.cdi.api) | ||
| implementation(libs.jakarta.inject.api) | ||
| implementation(libs.smallrye.common.annotation) | ||
| implementation(libs.slf4j.api) | ||
|
|
||
| testImplementation(platform(libs.junit.bom)) | ||
| testImplementation("org.junit.jupiter:junit-jupiter") | ||
| testImplementation(libs.mockito.core) | ||
| } |
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
45 changes: 45 additions & 0 deletions
45
.../impl/src/main/java/org/apache/polaris/extension/metrics/reports/NoOpMetricsReporter.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.polaris.extension.metrics.reports; | ||
|
|
||
| import io.smallrye.common.annotation.Identifier; | ||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import java.time.Instant; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
| import org.apache.iceberg.metrics.MetricsReport; | ||
| import org.apache.polaris.extension.metrics.IcebergMetricsReporter; | ||
|
|
||
| /** | ||
| * No-op implementation of {@link IcebergMetricsReporter} that silently discards all metrics. | ||
| * | ||
| * <p>Selected when {@code polaris.iceberg-metrics.reporting.type} is set to {@code "no-op"}. | ||
| */ | ||
| @ApplicationScoped | ||
| @Identifier("no-op") | ||
| public class NoOpMetricsReporter implements IcebergMetricsReporter { | ||
|
|
||
| @Override | ||
| public void reportMetric( | ||
| String catalogName, | ||
| long catalogId, | ||
| TableIdentifier table, | ||
| long tableId, | ||
| MetricsReport metricsReport, | ||
| Instant receivedTimestamp) {} | ||
| } | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| id("polaris-server") | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(platform(libs.iceberg.bom)) | ||
| implementation("org.apache.iceberg:iceberg-api") | ||
| } |
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
Oops, something went wrong.
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.
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.
Minor layering question: this is an implementation, but it lives in the
spimodule and pulls CDI annotations into the SPI artifact. It should go hand in hand along with LoggingMetricsReporter.Also, I'm a bit confused here, why we are having both no op and logging impls? which one is the default? thought this pr is meant to include default impl only? tho I think the other one can sneak in given it is straightforward.
IIUC, you are placing no op as the default? if so, lets update the javadoc accordingly as I pointed out above