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

Added support for custom exception handler for VertxPrometheusOptions… #214

Closed
wants to merge 0 commits into from

Conversation

swamymavuri
Copy link
Contributor

… (#213)

Motivation:

Explain here the context, and why you're making that change, what is the problem you're trying to solve.

Conformance:

Your commits should be signed and you should have signed the Eclipse Contributor Agreement as explained in https://github.com/eclipse/vert.x/blob/master/CONTRIBUTING.md
Please also make sure you adhere to the code style guidelines: https://github.com/vert-x3/wiki/wiki/Vert.x-code-style-guidelines

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Thanks for your proposal. Instead of adding an exception handler to options, it would be better to create a class that provides a request handler (similar to the scraping handler for vert.x web).
This way, the user can create the HTTP server without implementing the request handler and having full control on the server behavior.

@swamymavuri
Copy link
Contributor Author

Hi @tsegismont ,
Could you please review the following code changes as per your suggestions

Created a PrometheusRequestHandler class to manage Prometheus requests.
By default, PrometheusRequestHandler is used while creating HttpServer if embeddedServer is enabled.

and User can get the flexibility to create their own httpServer without implementing the request handler

Thanks

@tsegismont
Copy link
Contributor

Can you please sign the Eclipse Contributor Agreement and then, using the same Git author/user email, sign-off the commit?

@swamymavuri
Copy link
Contributor Author

Can you please sign the Eclipse Contributor Agreement and then, using the same Git author/user email, sign-off the commit?

Thanks @tsegismont , revalidated the commit by signing off the agreement.

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @swamymavuri

public class PrometheusRequestHandler implements Handler<HttpServerRequest> {

private final PrometheusMeterRegistry registry;
private final VertxPrometheusOptions options;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this to a String field that stores the embedded server endpoint? We don't need all of the options.


@Override
public void handle(HttpServerRequest request) {
if (options.getEmbeddedServerEndpoint().equals(request.path())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you can simplify the condition to use the string field

*
* @author Swamy Mavuri
*/
public class PrometheusRequestHandler implements Handler<HttpServerRequest> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please create an interface annotated with @VertxGen like the PrometheusScrapingHandler

@VertxGen
public interface PrometheusScrapingHandler {

  /**
   * Creates a Vert.x Web {@link io.vertx.ext.web.Route} handler for Prometheus metrics scraping.
   * The default backend registry is used.
   *
   * @return a {@link io.vertx.ext.web.Route} handler for the default backend registry
   * @see BackendRegistries#getDefaultNow()
   */
  static Handler<RoutingContext> create() {
    return new PrometheusScrapingHandlerImpl();
  }

If you do this, we will automatically have generated files for RxJava, Mutiny, ...etc

@tsegismont
Copy link
Contributor

Can you please also change the PR and issue titles and descriptions to reflect the new direction?

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

Successfully merging this pull request may close these issues.

None yet

2 participants