tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-2290) Metrics Microprofile Example for @Timed
Date Mon, 26 Nov 2018 16:01:00 GMT

    [ https://issues.apache.org/jira/browse/TOMEE-2290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16699186#comment-16699186
] 

ASF GitHub Bot commented on TOMEE-2290:
---------------------------------------

Github user rmannibucau commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/218#discussion_r236314041
  
    --- Diff: examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java ---
    @@ -0,0 +1,151 @@
    +/**
    + * 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
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * 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.
    + */
    +
    +import org.apache.cxf.jaxrs.client.WebClient;
    +import org.jboss.arquillian.container.test.api.Deployment;
    +import org.jboss.arquillian.junit.Arquillian;
    +import org.jboss.arquillian.test.api.ArquillianResource;
    +import org.jboss.shrinkwrap.api.ShrinkWrap;
    +import org.jboss.shrinkwrap.api.asset.StringAsset;
    +import org.jboss.shrinkwrap.api.spec.WebArchive;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +
    +import javax.json.Json;
    +import javax.json.JsonObject;
    +import javax.ws.rs.core.MediaType;
    +import javax.ws.rs.core.Response;
    +import java.io.StringReader;
    +import java.net.URL;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +@RunWith(Arquillian.class)
    +public class WeatherServiceTest {
    +
    +    @Deployment(testable = false)
    +    public static WebArchive createDeployment() {
    +        final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
    +                .addClass(WeatherService.class)
    +                .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
    +        return webArchive;
    +    }
    +
    +    @ArquillianResource
    +    private URL base;
    +
    +    @Test
    +    public void testTimedMetric() {
    +        WebClient.create(base.toExternalForm())
    --- End diff --
    
    WebClient is a CXF API, you can use the standard JAXRS Client https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Client.html


> Metrics Microprofile Example for @Timed
> ---------------------------------------
>
>                 Key: TOMEE-2290
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2290
>             Project: TomEE
>          Issue Type: Sub-task
>            Reporter: Ivan Junckes Filho
>            Assignee: Ivan Junckes Filho
>            Priority: Major
>              Labels: pull-request-available
>
> We would like to have an example for MicroProfile Metrics @Timed annotation.
> Here is a quick tutorial on MicroProfile Metrics if you are not aware:
> [https://www.tomitribe.com/blog/getting-started-with-microprofile-metrics/]
> Fork / clone the TomEE project from here:
> [https://github.com/apache/tomee]
> Example name should be _mp-metrics-timed_, following the standard already in the project.
> All the examples are in:
> [https://github.com/apache/tomee/tree/master/examples]
> See this example of @Counted for reference:
> [https://github.com/apache/tomee/tree/master/examples/mp-metrics-counted]
> See these two PRs for the diff for @Counted, it will help you see how simple it is:
> [https://github.com/apache/tomee/pull/203]
> [https://github.com/apache/tomee/pull/207]
> What you have to do is:
> 1 - Create a JAX-RS resource WeatherService that has one method with @Timed
> 2 - Have a WeatherServiceTest for the GET and OPTIONS scenarios of @Timed
> 3 - Make sure you have tests for Prometheus and JSON formats
> 4 - Make sure all the tests pass
> After that submit a PR and we'll review it.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message