dimas-b commented on code in PR #469:
URL: https://github.com/apache/polaris/pull/469#discussion_r1893194635


##########
service/common/src/main/java/org/apache/polaris/service/context/RealmContextResolverConfiguration.java:
##########
@@ -16,8 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-[org.apache.polaris.extension.persistence.impl.eclipselink.EclipseLinkPolarisMetaStoreManagerFactory]S
-contract={org.apache.polaris.core.persistence.MetaStoreManagerFactory}
-name=eclipse-link
-qualifier={io.smallrye.common.annotation.Identifier}
+package org.apache.polaris.service.context;
 
+public interface RealmContextResolverConfiguration {
+
+  enum Type {
+    DEFAULT,

Review Comment:
   Unused?



##########
service/common/src/main/java/org/apache/polaris/service/auth/TokenBrokerFactoryConfiguration.java:
##########
@@ -16,17 +16,29 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.polaris.service.dropwizard.test;
+package org.apache.polaris.service.auth;
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.Optional;
 
-/**
- * Annotation used to specify where to inject the Polaris test realm 
identifier. This is provided by
- * PolarisConnectionExtension.
- */
-@Target({ElementType.PARAMETER})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface PolarisRealm {}
+public interface TokenBrokerFactoryConfiguration {
+
+  TokenBrokerFactoryType type();
+
+  Duration maxTokenGeneration();
+
+  SymmetricKeyConfiguration symmetricKey();
+
+  enum TokenBrokerFactoryType {

Review Comment:
   This enum appears to be unused



##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/logging/QuarkusLoggingConfiguration.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.service.dropwizard.logging;
+
+import io.smallrye.config.ConfigMapping;
+import java.util.Map;
+
+@ConfigMapping(prefix = "polaris.log")
+public interface QuarkusLoggingConfiguration {

Review Comment:
   SGTM



##########
dropwizard/service/build.gradle.kts:
##########
@@ -17,13 +17,11 @@
  * under the License.
  */
 
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-
 plugins {
+  alias(libs.plugins.quarkus)

Review Comment:
   +1 to renaming later



##########
build.gradle.kts:
##########
@@ -32,6 +33,7 @@ plugins {
   id("eclipse")
   id("polaris-root")
   alias(libs.plugins.rat)
+  alias(libs.plugins.jandex) apply false

Review Comment:
   why `apply false`?



##########
dropwizard/service/src/main/resources/application.properties:
##########
@@ -0,0 +1,158 @@
+#
+# 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.
+#
+
+quarkus.application.name=Apache Polaris (incubating)
+quarkus.banner.path=/org/apache/polaris/service/banner.txt
+
+quarkus.config.mapping.validate-unknown=true
+
+quarkus.container-image.build=false
+quarkus.container-image.push=false
+# quarkus.container-image.registry=ghcr.io
+quarkus.container-image.group=apache
+quarkus.container-image.name=polaris
+# quarkus.container-image.tag=latest
+
+# multi-architecture builds require pushing to a registry
+# quarkus.docker.buildx.platform=linux/amd64,linux/arm64
+
+quarkus.http.auth.basic=false
+quarkus.http.access-log.enabled=true
+# quarkus.http.access-log.pattern=common
+quarkus.http.enable-compression=true
+quarkus.http.enable-decompression=true
+quarkus.http.body.handle-file-uploads=false
+quarkus.http.limits.max-body-size=10240K
+quarkus.http.compress-media-types=application/json,text/html,text/plain
+
+quarkus.http.cors.origins=http://localhost:8080
+quarkus.http.cors.methods=PATCH, POST, DELETE, GET, PUT
+quarkus.http.cors.headers=*
+quarkus.http.cors.exposed-headers=*
+quarkus.http.cors.access-control-max-age=PT10M
+quarkus.http.cors.access-control-allow-credentials=true
+
+quarkus.http.port=8181
+quarkus.http.test-port=0
+
+quarkus.log.level=INFO
+quarkus.log.console.enable=true
+quarkus.log.console.level=ALL
+quarkus.log.console.json=false
+quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] 
[%X{requestId},%X{realmId}] [%X{traceId},%X{parentId},%X{spanId},%X{sampled}] 
(%t) %s%e%n
+quarkus.log.file.enable=true
+quarkus.log.file.level=ALL
+quarkus.log.file.json=false
+quarkus.log.file.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] 
[%X{requestId},%X{realmId}] [%X{traceId},%X{parentId},%X{spanId},%X{sampled}] 
(%t) %s%e%n
+quarkus.log.file.path=./logs/polaris.log
+quarkus.log.file.rotation.file-suffix=.yyyy-MM-dd.gz
+quarkus.log.file.rotation.max-file-size=10M
+quarkus.log.file.rotation.max-backup-index=14
+quarkus.log.category."org.apache.polaris".level=INFO
+quarkus.log.category."org.apache.iceberg.rest".level=INFO
+quarkus.log.category."io.smallrye.config".level=INFO
+
+quarkus.management.enabled=true
+quarkus.management.port=8182
+quarkus.management.test-port=0
+
+quarkus.micrometer.enabled=true
+quarkus.micrometer.export.prometheus.enabled=true
+
+quarkus.otel.enabled=true
+quarkus.otel.sdk.disabled=false
+# quarkus.otel.exporter.otlp.endpoint=http://otlp-collector:4317
+# quarkus.otel.resource.attributes=deployment.environment=dev
+# quarkus.otel.service.name=polaris
+# quarkus.otel.traces.sampler=parentbased_always_on
+# quarkus.otel.traces.sampler.arg=1.0d
+
+polaris.context.realm-context-resolver.default-realm=default-realm
+polaris.context.realm-context-resolver.type=default
+
+polaris.config.defaults.ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING=false
+polaris.config.defaults.SUPPORTED_CATALOG_STORAGE_TYPES=["S3","GCS","AZURE","FILE"]
+# realm overrides
+# 
polaris.config.realm-overrides."my-realm".INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST=true
+# 
polaris.config.realm-overrides."my-realm".SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION=true
+
+polaris.persistence.metastore-manager.type=in-memory
+
+polaris.io.file-io-factory.type=default
+
+polaris.log.request-id-header-name=request_id
+# polaris.log.mdc.aid=polaris
+# polaris.log.mdc.sid=polaris-service
+
+polaris.metrics.tags.application=Polaris
+# polaris.metrics.tags.service=polaris
+# polaris.metrics.tags.environment=prod
+# polaris.metrics.tags.region=us-west-2
+
+# polaris.otel.span-attributes.service=polaris
+# polaris.otel.span-attributes.environment=prod
+# polaris.otel.span-attributes.region=us-west-2
+
+# polaris.tasks.max-concurrent-tasks=100
+# polaris.tasks.max-queued-tasks=1000
+
+polaris.rate-limiter.type=default
+polaris.rate-limiter.token-bucket.type=default
+polaris.rate-limiter.token-bucket.requests-per-second=9999
+polaris.rate-limiter.token-bucket.window=PT10S
+
+polaris.authentication.type=default
+polaris.authentication.oauth2-service.type=default
+polaris.authentication.token-broker-factory.type=rsa-key-pair

Review Comment:
   The default config fails to generate tokens with 
`java.lang.RuntimeException: Cannot find location for key 
LOCAL_PUBLIC_LOCATION_KEY`
   
   Would it make same to use the "no-op" broker (from #570) by default, to 
ensure same behaviour as current `main`?



##########
api/iceberg-service/build.gradle.kts:
##########
@@ -111,3 +112,5 @@ listOf("sourcesJar", "compileJava").forEach { task ->
 sourceSets {
   main { java { 
srcDir(project.layout.buildDirectory.dir("generated/src/main/java")) } }
 }
+
+tasks.named("javadoc") { dependsOn("jandex") }

Review Comment:
   why does `javadoc` have to depend on `jandex`? Did you mean `jar`?



##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/tracing/QuarkusTracingFilter.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.service.dropwizard.tracing;
+
+import io.opentelemetry.api.trace.Span;
+import io.quarkus.vertx.web.RouteFilter;
+import io.vertx.ext.web.RoutingContext;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.apache.polaris.service.dropwizard.logging.QuarkusLoggingMDCFilter;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+public class QuarkusTracingFilter {
+
+  public static final String REQUEST_ID_ATTRIBUTE = "polaris.request.id";
+  public static final String REALM_ID_ATTRIBUTE = "polaris.realm";
+
+  @ConfigProperty(name = "quarkus.otel.sdk.disabled")
+  boolean sdkDisabled;
+
+  @Inject QuarkusTelemetryConfiguration telemetryConfiguration;
+
+  @RouteFilter(QuarkusLoggingMDCFilter.PRIORITY - 1)
+  public void applySpanAttributes(RoutingContext rc) {
+    if (!sdkDisabled) {
+      Span span = Span.current();
+      telemetryConfiguration.spanAttributes().forEach(span::setAttribute);

Review Comment:
   For global properties it is probably more efficient to use resource 
attributes as opposed to span attributes, but we can deal with that later.



##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/task/QuarkusTaskExecutorImpl.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.service.dropwizard.task;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.Context;
+import io.opentelemetry.context.Scope;
+import io.quarkus.runtime.Startup;
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import java.util.concurrent.ExecutorService;
+import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.service.dropwizard.tracing.QuarkusTracingFilter;
+import org.apache.polaris.service.task.TaskExecutorImpl;
+import org.apache.polaris.service.task.TaskFileIOSupplier;
+
+@ApplicationScoped
+public class QuarkusTaskExecutorImpl extends TaskExecutorImpl {
+
+  private final Tracer tracer;
+
+  public QuarkusTaskExecutorImpl() {
+    this(null, null, null, null);
+  }
+
+  @Inject
+  public QuarkusTaskExecutorImpl(
+      @Identifier("task-executor") ExecutorService executorService,
+      MetaStoreManagerFactory metaStoreManagerFactory,
+      TaskFileIOSupplier fileIOSupplier,
+      Tracer tracer) {
+    super(executorService, metaStoreManagerFactory, fileIOSupplier);
+    this.tracer = tracer;
+  }
+
+  @Startup
+  @Override
+  public void init() {
+    super.init();
+  }
+
+  @Override
+  protected void handleTask(long taskEntityId, CallContext callContext, int 
attempt) {
+    Span span =
+        tracer
+            .spanBuilder("polaris.task")
+            .setParent(Context.current())
+            .setAttribute(
+                QuarkusTracingFilter.REALM_ID_ATTRIBUTE,
+                callContext.getRealmContext().getRealmIdentifier())
+            .setAttribute("polaris.task.entity.id", taskEntityId)
+            .setAttribute("polaris.task.attempt", attempt)
+            .startSpan();
+    try (Scope ignored = span.makeCurrent()) {
+      super.handleTask(taskEntityId, callContext, attempt);
+    } finally {
+      span.end();
+    }

Review Comment:
   Could we use `@WithSpan` and `@SpanAttribute` at the method level? (ok to 
defer)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to