Copilot commented on code in PR #4773: URL: https://github.com/apache/polaris/pull/4773#discussion_r3413935372
########## site/content/in-dev/unreleased/events.md: ########## @@ -0,0 +1,127 @@ +--- +# +# 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. +# +title: Events +type: docs +weight: 460 +--- + +Polaris emits events for catalog, namespace, table, view, policy, principal, task, and other +server-side operations. Events can be delivered to configured event listeners for auditing, +observability, or downstream processing. + +Each event has: + +- `type`: the event type, such as `BEFORE_CREATE_TABLE` or `AFTER_CREATE_TABLE`. +- `metadata`: event metadata, including the event ID, timestamp, realm ID, user, request ID, and + OpenTelemetry context. +- `attributes`: typed operation-specific values, such as `catalog_name`, `table_name`, or request + and response objects. + +Built-in event types and categories are defined in the [`EventType`] class. + +Built-in attribute names are defined in the [`EventAttributes`] class. Custom attributes can be +added by event emitters and listeners. + +[`EventType`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventType.java + +[`EventAttributes`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/EventAttributes.java Review Comment: The text refers to an `EventType` class, but the link target is `PolarisEventType.java`. Renaming the link label and reference here would avoid confusing readers and keep the docs aligned with the codebase naming. ########## site/content/in-dev/unreleased/events.md: ########## @@ -0,0 +1,127 @@ +--- +# +# 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. +# +title: Events +type: docs +weight: 460 +--- + +Polaris emits events for catalog, namespace, table, view, policy, principal, task, and other +server-side operations. Events can be delivered to configured event listeners for auditing, +observability, or downstream processing. + +Each event has: + +- `type`: the event type, such as `BEFORE_CREATE_TABLE` or `AFTER_CREATE_TABLE`. +- `metadata`: event metadata, including the event ID, timestamp, realm ID, user, request ID, and + OpenTelemetry context. +- `attributes`: typed operation-specific values, such as `catalog_name`, `table_name`, or request + and response objects. + +Built-in event types and categories are defined in the [`EventType`] class. + +Built-in attribute names are defined in the [`EventAttributes`] class. Custom attributes can be +added by event emitters and listeners. + +[`EventType`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventType.java + +[`EventAttributes`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/EventAttributes.java + +## Configuring Event Listeners + +Enable event listeners with `polaris.event-listener.types`. The value is a comma-separated list of +registered event listener identifiers. Polaris includes listener implementations such as +`persistence-in-memory-buffer` and `aws-cloudwatch`. + +```properties +polaris.event-listener.types=persistence-in-memory-buffer,aws-cloudwatch +``` + +By default, a configured listener receives all event types. You can restrict a listener to selected +event types or categories: + +```properties +polaris.event-listener.types=aws-cloudwatch +polaris.event-listener.aws-cloudwatch.enabled-event-categories=TABLE,VIEW +polaris.event-listener.aws-cloudwatch.enabled-event-types=AFTER_CREATE_NAMESPACE +``` + +When both event categories and event types are configured for a listener, the listener receives the +union of both selections. + +## Event Filters + +Event filters let you route only matching events to selected listeners. Filters are named +independently of listeners, then mapped to one or more listener identifiers. + +The only supported filter type is `jakarta-el`. Jakarta Expression Language predicates can read +these beans: + +- `type`: the event type. +- `metadata`: the event metadata. +- `attributes`: the event attribute map. + +Use `==` for equality comparisons. Event attributes can be accessed by name, for example +`attributes.catalog_name`, or with bracket notation, for example `attributes['table_name']`. + Review Comment: The docs imply that any event attribute can be accessed by name from EL filters, but the current resolver only recognizes attribute names that exist in `EventAttributes` (unknown names raise `PropertyNotFoundException` and the event is dropped). Please clarify this limitation here so operators don't assume custom attributes are filterable by name. ########## site/content/in-dev/unreleased/events.md: ########## @@ -0,0 +1,127 @@ +--- +# +# 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. +# +title: Events +type: docs +weight: 460 +--- + +Polaris emits events for catalog, namespace, table, view, policy, principal, task, and other +server-side operations. Events can be delivered to configured event listeners for auditing, +observability, or downstream processing. + +Each event has: + +- `type`: the event type, such as `BEFORE_CREATE_TABLE` or `AFTER_CREATE_TABLE`. +- `metadata`: event metadata, including the event ID, timestamp, realm ID, user, request ID, and + OpenTelemetry context. +- `attributes`: typed operation-specific values, such as `catalog_name`, `table_name`, or request + and response objects. + +Built-in event types and categories are defined in the [`EventType`] class. + +Built-in attribute names are defined in the [`EventAttributes`] class. Custom attributes can be +added by event emitters and listeners. + +[`EventType`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventType.java + +[`EventAttributes`]: https://github.com/apache/polaris/blob/main/runtime/service/src/main/java/org/apache/polaris/service/events/EventAttributes.java + +## Configuring Event Listeners + +Enable event listeners with `polaris.event-listener.types`. The value is a comma-separated list of +registered event listener identifiers. Polaris includes listener implementations such as +`persistence-in-memory-buffer` and `aws-cloudwatch`. + +```properties +polaris.event-listener.types=persistence-in-memory-buffer,aws-cloudwatch +``` + +By default, a configured listener receives all event types. You can restrict a listener to selected +event types or categories: + +```properties +polaris.event-listener.types=aws-cloudwatch +polaris.event-listener.aws-cloudwatch.enabled-event-categories=TABLE,VIEW +polaris.event-listener.aws-cloudwatch.enabled-event-types=AFTER_CREATE_NAMESPACE +``` + +When both event categories and event types are configured for a listener, the listener receives the +union of both selections. + +## Event Filters + +Event filters let you route only matching events to selected listeners. Filters are named +independently of listeners, then mapped to one or more listener identifiers. + +The only supported filter type is `jakarta-el`. Jakarta Expression Language predicates can read +these beans: Review Comment: Jakarta EL expressions are evaluated in-process and can invoke methods on the exposed beans. It would be safer to document that filter expressions are a privileged, operator-controlled configuration and should not be sourced from untrusted input. ########## runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventFilterConfiguration.java: ########## @@ -0,0 +1,58 @@ +/* + * 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.events; + +import io.quarkus.runtime.annotations.StaticInitSafe; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithParentName; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +@StaticInitSafe +@ConfigMapping(prefix = "polaris.event-filter") +public interface PolarisEventFilterConfiguration { + + /** Configuration of each named event filter. */ + @WithParentName + Map<String, FilterConfiguration> filters(); + + interface FilterConfiguration { + + /** The event filter implementation type. Currently supported: {@code jakarta-el}. */ + String type(); + + /** Comma-separated list of event listener identifiers this filter applies to. */ + Optional<Set<String>> listeners(); + + /** + * For Jakarta EL filters only. The expression that events must match. The expression has access + * to {@code type}, {@code metadata}, and {@code attributes}. Use {@code ==} for equality + * predicates. + */ + Optional<String> include(); + + /** + * For Jakarta EL filters only. The expression that events must not match. The expression has + * access to {@code type}, {@code metadata}, and {@code attributes}. Use {@code ==} for equality + * predicates. + */ + Optional<String> exclude(); Review Comment: The EL filter implementation currently resolves `attributes.<name>` via `EventAttributes.findByName(...)`, so only built-in attributes are addressable by name. Adding this limitation to the config mapping Javadoc will help the generated configuration docs reflect actual behavior. -- 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]
