You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wankai123 (via GitHub)" <gi...@apache.org> on 2026/01/20 08:39:39 UTC

[PR] PromQL service: fix time parse issue when using RFC3339 time format for querying. [skywalking]

wankai123 opened a new pull request, #13677:
URL: https://github.com/apache/skywalking/pull/13677

   now, support the following format:
   ```
     "2026-01-20T03:27:18Z",
     "2026-01-20T03:27:18.0Z",
     "2026-01-20T03:27:18.000Z",
     "2026-01-20T03:27:18.123Z",
     "2026-01-20T11:27:18+08:00",
     "2026-01-20T11:27:18.0+08:00",
     "2026-01-20T11:27:18.123+08:00",
     "2026-01-20T11:27:18+0800",
     "2026-01-20T11:27:18.0+0800",
     "2026-01-20T11:27:18.123+0800",
     "2026-01-19T19:27:18-08:00",
     "2026-01-19T19:27:18.0-08:00",
     "2026-01-19T19:27:18.123-08:00",
     "2026-01-19T19:27:18-0800",
     "2026-01-19T19:27:18.0-0800",
     "2026-01-19T19:27:18.123-0800",
     "2026-01-20T03:27:18"
   ```
   
   - [X] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #13675.
   - [X] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PromQL service: fix time parse issue when using RFC3339 time format for querying. [skywalking]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13677:
URL: https://github.com/apache/skywalking/pull/13677#discussion_r2707341866


##########
oap-server/server-query-plugin/promql-plugin/src/test/java/org/apache/skywalking/promql/handler/PromQLApiHandlerTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.skywalking.promql.handler;
+
+import java.time.OffsetDateTime;
+import org.apache.skywalking.oap.query.promql.handler.PromQLApiHandler;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class PromQLApiHandlerTest {
+
+    @Test
+    public void testRFC3399Parse() {

Review Comment:
   The test method name contains a typo. It should be "testRFC3339Parse" instead of "testRFC3399Parse" to correctly reference the RFC 3339 standard.
   ```suggestion
       public void testRFC3339Parse() {
   ```



##########
oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java:
##########
@@ -597,7 +613,8 @@ private static long formatTimestamp2Millis(String timestamp) {
             time = Double.valueOf(timestamp).longValue() * 1000;
         } catch (NumberFormatException e) {
             // if RFC3399 format, such as 2024-09-19T20:11:00.781Z
-            time = ISODateTimeFormat.dateTime().parseMillis(timestamp);
+            OffsetDateTime odt = OffsetDateTime.parse(timestamp, RFC3339_FORMATTER);
+            time = odt.toEpochSecond() * 1000;

Review Comment:
   The conversion from OffsetDateTime to milliseconds only uses seconds precision (toEpochSecond() * 1000), which discards any millisecond information present in the timestamp. For timestamps like "2026-01-20T03:27:18.123Z", the .123 milliseconds will be lost. Consider using odt.toInstant().toEpochMilli() instead to preserve millisecond precision.
   ```suggestion
               time = odt.toInstant().toEpochMilli();
   ```



##########
oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java:
##########
@@ -597,7 +613,8 @@ private static long formatTimestamp2Millis(String timestamp) {
             time = Double.valueOf(timestamp).longValue() * 1000;
         } catch (NumberFormatException e) {
             // if RFC3399 format, such as 2024-09-19T20:11:00.781Z

Review Comment:
   The comment references "RFC3399" but the correct standard name is "RFC3339". This should be corrected for accuracy.
   ```suggestion
               // if RFC3339 format, such as 2024-09-19T20:11:00.781Z
   ```



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PromQL service: fix time parse issue when using RFC3339 time format for querying. [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #13677:
URL: https://github.com/apache/skywalking/pull/13677


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PromQL service: fix time parse issue when using RFC3339 time format for querying. [skywalking]

Posted by "wankai123 (via GitHub)" <gi...@apache.org>.
wankai123 commented on code in PR #13677:
URL: https://github.com/apache/skywalking/pull/13677#discussion_r2707420637


##########
oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java:
##########
@@ -597,7 +613,8 @@ private static long formatTimestamp2Millis(String timestamp) {
             time = Double.valueOf(timestamp).longValue() * 1000;
         } catch (NumberFormatException e) {
             // if RFC3399 format, such as 2024-09-19T20:11:00.781Z
-            time = ISODateTimeFormat.dateTime().parseMillis(timestamp);
+            OffsetDateTime odt = OffsetDateTime.parse(timestamp, RFC3339_FORMATTER);
+            time = odt.toEpochSecond() * 1000;

Review Comment:
   don't require milliseconds



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org