cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Appdynamics to monitor java httpclient and clientbuilder?

carlos.aguni
Builder

Hi all i wrote a dummy java/quarkus app that fetches html data from any web page.

my goal is to see the tier pointing to the endpoints in appdy's flowmap

 

my code

@GET
    @Path("/1")
    @Produces(MediaType.TEXT_PLAIN)
    public String test1(){
        try {
            CloseableHttpClient httpClient = HttpClients
                    .custom()
                    .setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, TrustAllStrategy.INSTANCE).build())
                    .build();
            HttpGet request = new HttpGet("https://nylen.io/d3-spirograph/");
            CloseableHttpResponse response = httpClient.execute(request);
            System.out.println(response.getProtocolVersion());              // HTTP/1.1
            System.out.println(response.getStatusLine().getStatusCode());   // HTTP/1.1
            System.out.println(response.getStatusLine().getReasonPhrase()); // OK
            System.out.println(response.getStatusLine().toString());        // HTTP/1.1 200 OK

            HttpEntity entity = response.getEntity();
            if (entity != null){
                String result = EntityUtils.toString(entity);
                response.close();
                return result;
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        } catch (KeyManagementException e) {
            e.printStackTrace();
        }

        return "ok";
    }

 

path /2

@GET
    @Path("/2")
    @Produces(MediaType.TEXT_PLAIN)
    public String test2() throws Exception{

        SSLContext sslcontext = SSLContext.getInstance("TLS");

        sslcontext.init(null, new TrustManager[]{new X509TrustManager() {
            public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
            public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
            public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
        }}, new java.security.SecureRandom());

//        Client client = ClientBuilder.newClient()
        Client client = ClientBuilder.newBuilder()
                                .sslContext(sslcontext)
                                .hostnameVerifier((s1, s2) -> true)
                                .build();
        String ssb = "https://self-signed.badssl.com/";
        String response = client.target(ssb)
                //.queryParam("query", "q")
                .request()
                .accept("text/html")
                .get(String.class);
//                .post(Entity.entity("e", "text/plain"), String.class);
        client.close();
        return response;
    }

 

 

start app

java -javaagent:/opt/appdynamics-agent/ver21.8.0.32958/javaagent.jar \
     -jar /root/quarkus/vintageStore/rest-book/target/quarkus-app/quarkus-run.jar

starting logs

...
Agent runtime conf directory set to /opt/appdynamics-agent/ver21.8.0.32958/conf
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: AgentInstallManager - Agent runtime conf directory set to /opt/appdynamics-agent/ver21.8.0.32958/conf
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - JDK Compatibility: 1.8+
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - Using Java Agent Version [Server Agent #21.8.0.32958 v21.8.0 GA compatible with 4.4.1.0 r38646896978b0b95298354a38b015eaede619691 release/21.8.0]
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - Running IBM Java Agent [No]
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - Java Agent Directory [/opt/appdynamics-agent/ver21.8.0.32958]
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - Java Agent AppAgent directory [/opt/appdynamics-agent/ver21.8.0.32958]
Agent logging directory set to [/opt/appdynamics-agent/ver21.8.0.32958/logs]
[AD Agent init] Tue Oct 19 01:26:51 BRT 2021[INFO]: JavaAgent - Agent logging directory set to [/opt/appdynamics-agent/ver21.8.0.32958/logs]
getBootstrapResource not available on ClassLoader
Registered app server agent with Node ID[234307] Component ID[94762] Application ID [55102]
Started AppDynamics Java Agent Successfully.
  ____              _

 

 

problem is i can not see "Service Endponits" being discovered.

 

java-appdy-notworking.PNG

 

 

 

 

 

3 REPLIES 3

carlos.aguni
Builder

ok so this might be a problem.. but there's no solution at least in the page

 

https://docs.appdynamics.com/21.6/en/application-monitoring/install-app-server-agents/java-agent/tra...

 

https://docs.appdynamics.com/21.9/en/application-monitoring/install-app-server-agents/java-agent/jav....

Apache

Apache HTTP Client

-

HTTPClient (now in Apache HTTP Components)

Yes

Yes (correlation only)

Yes

-

Yes

See "HTTP Backends" on Java Backend Detection

 

 

the only thing i can see is DefaultChannelHandlerContext inside Thread Tasks.

quarkus-metric-browser-thread-task.PNG

 

regards,C

 

got it to work

thank you

need to add

 

-Dappdynamics.async.instrumentation.strategy=constructor

 

https://docs.appdynamics.com/21.6/en/application-monitoring/install-app-server-agents/java-agent/con...

Hi @carlos.aguni,

 

Thank you for following back up on your post with the solution. We love to see this in the community.


Thanks,

Ryan, Cisco AppDynamics Community Manager




Found something helpful? Click the Accept as Solution button to help others find answers faster.

Liked something? Click the Thumbs Up button.



Check out Observabiity in Action

new deep dive videos weekly in the Knowledge Base.