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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
