Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-37601] Remove Unirest dependency in PrometheusReporterTest #26387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

r-sidd
Copy link
Contributor

@r-sidd r-sidd commented Apr 1, 2025

What is the purpose of the change

Remove Unirest dependency in PrometheusReporterTest

Brief change log

This change removes the dependency on the Unirest HTTP client library. Unirest was only used in PrometheusReporterTest for polling metrics. This commit replaces the single usage of Unirest.get() with the standard Java HttpClient, reducing external dependencies.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): yes
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 1, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@hlteoh37
Copy link
Contributor

hlteoh37 commented Apr 2, 2025

Thanks for this contribution @r-sidd ! Library upgrade LGTM.

However, since we only use Unirest in one specific place for testing,
https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java#L248

Maybe we can consider instead removing the dependency on Unirest altogether by replacing the call Unirest.get() with calls to Java's default HttpClient instead?


    private static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient();

    static HttpResponse<String> pollMetrics(int port) throws IOException, InterruptedException {
        return HTTP_CLIENT.send(
                HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:" + port + "/metrics"))
                .GET()
                .build(), HttpResponse.BodyHandlers.ofString());
    }

A bit more verbose, but reduces dependencies when needed!

@r-sidd
Copy link
Contributor Author

r-sidd commented Apr 2, 2025

Thanks for this contribution @r-sidd ! Library upgrade LGTM.

However, since we only use Unirest in one specific place for testing, https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java#L248

Maybe we can consider instead removing the dependency on Unirest altogether by replacing the call Unirest.get() with calls to Java's default HttpClient instead?


    private static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient();

    static HttpResponse<String> pollMetrics(int port) throws IOException, InterruptedException {
        return HTTP_CLIENT.send(
                HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:" + port + "/metrics"))
                .GET()
                .build(), HttpResponse.BodyHandlers.ofString());
    }

A bit more verbose, but reduces dependencies when needed!

Yea sure, does makes sense. Do you want me to make these changes in this PR itself? If so do let me know, will make the changes :)

@r-sidd r-sidd requested a review from hlteoh37 April 3, 2025 10:48
@r-sidd
Copy link
Contributor Author

r-sidd commented Apr 3, 2025

Hi @hlteoh37, thanks for the suggestion and the code, I've made the changes and pushed :)

@davidradl
Copy link
Contributor

@r-sidd this last change looks good. Please could you amend the Jira and PR title and text to describe the problem you are now fixing.

@r-sidd
Copy link
Contributor Author

r-sidd commented Apr 4, 2025

@r-sidd this last change looks good. Please could you amend the Jira and PR title and text to describe the problem you are now fixing.

Yes sure, let me do that

@r-sidd r-sidd changed the title [FLINK-37601] migrate unirest-java to unirest-java-core [FLINK-37601] remove Unirest dependency and use default HTTP library Apr 4, 2025
@r-sidd r-sidd changed the title [FLINK-37601] remove Unirest dependency and use default HTTP library [FLINK-37601] Remove Unirest dependency in PrometheusReporterTest Apr 4, 2025
@r-sidd
Copy link
Contributor Author

r-sidd commented Apr 4, 2025

@r-sidd this last change looks good. Please could you amend the Jira and PR title and text to describe the problem you are now fixing.

@davidradl I've updated the Jira and the PR details :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants