Splunk AppDynamics

Appdynamics to monitor java httpclient and clientbuilder?

carlos_aguni
Explorer

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.

image.png

Labels (1)
0 Karma
1 Solution

carlos_aguni
Explorer

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...

View solution in original post

carlos_aguni
Explorer

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.

image.png

regards,C

0 Karma

carlos_aguni
Explorer

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...

iamryan
Community Manager
Community Manager

Hi @carlos.aguni,

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

0 Karma
Get Updates on the Splunk Community!

Uncovering Multi-Account Fraud with Splunk Banking Analytics

Last month, I met with a Senior Fraud Analyst at a nationally recognized bank to discuss their recent success ...

Secure Your Future: A Deep Dive into the Compliance and Security Enhancements for the ...

What has been announced?  In the blog, “Preparing your Splunk Environment for OpensSSL3,”we announced the ...

New This Month in Splunk Observability Cloud - Synthetic Monitoring updates, UI ...

This month, we’re delivering several platform, infrastructure, application and digital experience monitoring ...