Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
### Deprecations

* The property `polaris.active-roles-provider.type` is deprecated and has no effect anymore.
* The property `polaris.log.request-id-header-name` has been renamed to
`polaris.tracing.request-id-generator.header-name`; the old name is still supported for backwards
compatibility, but will generate a warning.
Comment on lines +56 to +58
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use word deperecated ?


### Fixes

Expand Down
4 changes: 3 additions & 1 deletion runtime/defaults/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ polaris.event-listener.type=no-op
# polaris.event-listener.persistence-in-memory-buffer.buffer-time=5000ms
# polaris.event-listener.persistence-in-memory-buffer.max-buffer-size=5

polaris.log.request-id-header-name=Polaris-Request-Id
# polaris.log.mdc.aid=polaris
# polaris.log.mdc.sid=polaris-service

Expand All @@ -146,6 +145,9 @@ polaris.metrics.tags.application=Polaris
# polaris.metrics.tags.environment=prod
# polaris.metrics.tags.region=us-west-2

polaris.tracing.request-id-generator.type=default
polaris.tracing.request-id-generator.header-name=Polaris-Request-Id
Copy link
Contributor

Choose a reason for hiding this comment

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

minor / optional : does the header name has to to do anything with the generator, wondering if we just reuse the name we had earlier, WDYT ?

Suggested change
polaris.tracing.request-id-generator.header-name=Polaris-Request-Id
polaris.tracing.request-id-header-name=Polaris-Request-Id


# polaris.tasks.max-concurrent-tasks=100
# polaris.tasks.max-queued-tasks=1000

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.config;

import io.smallrye.config.RelocateConfigSourceInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConfigRelocationInterceptor extends RelocateConfigSourceInterceptor {

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigRelocationInterceptor.class);

public ConfigRelocationInterceptor() {
super(ConfigRelocationInterceptor::applyRelocations);
}

private static String applyRelocations(String name) {
if (name.equals("polaris.log.request-id-header-name")) {
String replacement = "polaris.tracing.request-id-generator.header-name";
LOGGER.warn("Property '{}' is deprecated, use '{}' instead", name, replacement);
return replacement;
}
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
import org.apache.polaris.service.storage.aws.S3AccessConfig;
import org.apache.polaris.service.storage.aws.StsClientsPool;
import org.apache.polaris.service.task.TaskHandlerConfiguration;
import org.apache.polaris.service.tracing.RequestIdGenerator;
import org.apache.polaris.service.tracing.TracingConfiguration;
import org.eclipse.microprofile.context.ManagedExecutor;
import org.eclipse.microprofile.context.ThreadContext;
import org.slf4j.Logger;
Expand Down Expand Up @@ -392,6 +394,15 @@ public OidcTenantResolver oidcTenantResolver(
return resolvers.select(Identifier.Literal.of(config.tenantResolver())).get();
}

@Produces
@ApplicationScoped
public RequestIdGenerator requestIdGenerator(
TracingConfiguration config, @Any Instance<RequestIdGenerator> requestIdGenerators) {
return requestIdGenerators
.select(Identifier.Literal.of(config.requestIdGenerator().type()))
.get();
}

public void closeTaskExecutor(@Disposes @Identifier("task-executor") ManagedExecutor executor) {
executor.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
@ConfigMapping(prefix = "polaris.log")
public interface LoggingConfiguration {

/** The name of the header that contains the request ID. */
String requestIdHeaderName();

/** Additional MDC values to include in the log context. */
Map<String, String> mdc();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.polaris.service.tracing;

import io.smallrye.common.annotation.Identifier;
import io.smallrye.mutiny.Uni;
import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -37,6 +38,7 @@
* reset to 1.
*/
@ApplicationScoped
@Identifier("default")
public class DefaultRequestIdGenerator implements RequestIdGenerator {

record RequestId(UUID uuid, long counter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import jakarta.ws.rs.core.Response;
import org.apache.iceberg.rest.responses.ErrorResponse;
import org.apache.polaris.service.config.FilterPriorities;
import org.apache.polaris.service.logging.LoggingConfiguration;
import org.jboss.resteasy.reactive.server.ServerRequestFilter;
import org.jboss.resteasy.reactive.server.ServerResponseFilter;
import org.slf4j.Logger;
Expand All @@ -38,12 +37,12 @@ public class RequestIdFilter {

private static final Logger LOGGER = LoggerFactory.getLogger(RequestIdFilter.class);

@Inject LoggingConfiguration loggingConfiguration;
@Inject TracingConfiguration tracingConfiguration;
@Inject RequestIdGenerator requestIdGenerator;

@ServerRequestFilter(preMatching = true, priority = FilterPriorities.REQUEST_ID_FILTER)
public Uni<Response> assignRequestId(ContainerRequestContext rc) {
var requestId = rc.getHeaderString(loggingConfiguration.requestIdHeaderName());
var requestId = rc.getHeaderString(tracingConfiguration.requestIdGenerator().headerName());
return (requestId != null
? Uni.createFrom().item(requestId)
: requestIdGenerator.generateRequestId(rc))
Expand All @@ -58,7 +57,7 @@ public void addResponseHeader(
ContainerRequestContext request, ContainerResponseContext response) {
String requestId = (String) request.getProperty(REQUEST_ID_KEY);
if (requestId != null) { // can be null if request ID generation fails
response.getHeaders().add(loggingConfiguration.requestIdHeaderName(), requestId);
response.getHeaders().add(tracingConfiguration.requestIdGenerator().headerName(), requestId);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.tracing;

import io.smallrye.config.ConfigMapping;

@ConfigMapping(prefix = "polaris.tracing")
public interface TracingConfiguration {

RequestIdGenerator requestIdGenerator();

interface RequestIdGenerator {

/**
* The type of the request ID generator. Must be a registered {@link RequestIdGenerator}
* identifier.
*/
String type();

/**
* The name of the request header that contains the request ID. Used by the default request ID
* generator.
*/
String headerName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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.
#

org.apache.polaris.service.config.ConfigRelocationInterceptor
Copy link
Contributor

Choose a reason for hiding this comment

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

nit : newline ?

Loading