adnanhemani commented on code in PR #2720:
URL: https://github.com/apache/polaris/pull/2720#discussion_r2397894164


##########
runtime/service/src/main/java/org/apache/polaris/service/tracing/DefaultRequestIdGenerator.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.mutiny.Uni;
+import jakarta.annotation.Nonnull;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Default implementation of {@link RequestIdGenerator}, striking a balance 
between randomness and
+ * performance.
+ *
+ * <p>The IDs generated by this generator are of the form: {@code 
UUID_COUNTER}. The UUID part is
+ * randomly generated at startup, and the counter is incremented for each 
request.
+ *
+ * <p>In the unlikely event that the counter overflows, a new UUID is 
generated and the counter is
+ * reset to 1.
+ */
+@ApplicationScoped
+public class DefaultRequestIdGenerator implements RequestIdGenerator {
+
+  record RequestId(UUID uuid, long counter) {
+
+    RequestId() {
+      this(UUID.randomUUID(), 1);
+    }
+
+    @Override
+    @Nonnull
+    public String toString() {
+      return String.format("%s_%019d", uuid(), counter());

Review Comment:
   Personally, I think it's fine if the requests are only lexicographically 
sorted across all requests made per node. IMO request ID sorting doesn't mean 
much for API clients as they also usually log timestamps.
   
   I'm okay to change it, if you both feel there's something better - but just 
my two cents 😃



-- 
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