close
Skip to content

[Fix][Connector-V2] Fix prometheus check time can not parse double value#9311

Merged
hailin0 merged 7 commits into
apache:devfrom
chl-wxp:bugfix/dev-fix-prometheus-check-time-error-bug
May 21, 2025
Merged

[Fix][Connector-V2] Fix prometheus check time can not parse double value#9311
hailin0 merged 7 commits into
apache:devfrom
chl-wxp:bugfix/dev-fix-prometheus-check-time-error-bug

Conversation

@chl-wxp

@chl-wxp chl-wxp commented May 13, 2025

Copy link
Copy Markdown
Member

Purpose of this pull request

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@hailin0 hailin0 requested a review from Copilot May 14, 2025 09:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes a bug in the Prometheus connector related to time parameter parsing for Prometheus checks. Key changes include:

  • Adding comprehensive tests in PrometheusParamCheckTest to validate multiple time formats.
  • Modifying the time validation in PrometheusSourceParameter to support numeric timestamps.
  • Updating the ISO8601 parsing to use Instant.parse for improved clarity.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
seatunnel-connectors-v2/connector-prometheus/src/test/java/org/apache/seatunnel/connectors/seatunnel/prometheus/PrometheusParamCheckTest.java Added test cases to cover valid ISO8601, numeric, and CURRENT_TIMESTAMP time formats.
seatunnel-connectors-v2/connector-prometheus/src/main/java/org/apache/seatunnel/connectors/seatunnel/prometheus/config/PrometheusSourceParameter.java Updated checkTimeParam to change ISO8601 parsing and to validate numeric time parameters.

ZonedDateTime now = ZonedDateTime.now();
return now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}
if (!time.endsWith("Z")) {

Copilot AI May 14, 2025

Copy link

Choose a reason for hiding this comment

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

The 'checkTimeParam' method does not handle the 'CURRENT_TIMESTAMP' format, which is expected by test cases (e.g., map4). Consider adding an explicit check for 'CURRENT_TIMESTAMP' before attempting to parse the value as a number.

Copilot uses AI. Check for mistakes.
@hailin0

hailin0 commented May 14, 2025

Copy link
Copy Markdown
Member

waiting for ci passed

ZonedDateTime now = ZonedDateTime.now();
return now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}
if (!time.endsWith("Z")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move it under isValidISO8601 method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

moved

@Hisoka-X Hisoka-X left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM if ci passes.

@Hisoka-X Hisoka-X changed the title [Bugfix] [Connector-V2]fix prometheus check time error bug [Fix][Connector-V2] Fix prometheus check time can not parse double value May 21, 2025
@hailin0 hailin0 merged commit fbf7872 into apache:dev May 21, 2025
dybyte pushed a commit to dybyte/seatunnel that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants