Amazon CodeGuru

Hands-On

Demo

In this demo, we will:

  1. Set up a GitHub repository with sample Java code
  2. Associate the repository with CodeGuru Reviewer
  3. Trigger a code review and analyze recommendations
  4. Create a sample Java application for profiling
  5. Configure CodeGuru Profiler
  6. Run the application with the Profiler agent
  7. Analyze performance insights and recommendations
  8. Test the setup
  9. Clean up resources

Agenda

Create GitHub repository

codeguru-demo

Create repository

Create new file

src/main/java/com/example/ShoppingCart.java

Commit changes

Amazon CodeGuru

Welcome screen

Associate repository and run analysis

Connect to your GitHub account

Authorize Amazon CodeGuru Reviewer

Repository location

Source branch

Associate repository and run analysis

Code reviews

Completed

Full repository analysis

Recommendations

Recommendations

Create new file

src/main/java/com/example/ProfilerDemo.java

Commit changes

Create new file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.example</groupId>
    <artifactId>codeguru-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>
pom.xml

Commit changes

Copy Clone URL 

git clone https://github.com/learnpde/codeguru-demo.git
cd codeguru-demo
mvn clean compile

Create profiling group

demo-profiling-group

Profiling group details

Setup Instructions

Create IAM User

codeguru-user

Set permissions

Review and create

User created successfully

Add User to demo-profiling group 

Successfully updated permissions for profiling group

Start agent

Create access key for IAM User

Use case

Set description tag - optional

Retrieve access keys

Don't click Done
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_REGION=us-east-1
java -javaagent:../codeguru-profiler-java-agent-standalone-1.2.4.jar=\
"profilingGroupName:demo-profiling-group,heapSummaryEnabled:true" \
-cp target/classes \
com.example.ProfilerDemo

Profiling data received

Pending

Pending

Profiling Summary received                              

Profiling Summary received                              

CPU

Latency

Heap summary

Report

Clean Up

Delete profiling group

Delete profiling group

Disassociate repository

Disassociate repository

Disassociating

Delete GitHub Repository 

learnpde/codeguru-demo

Delete this repository

Delete IAM User 

Deactivate access key

confirm
cd ..
rm -rf codeguru-demo
rm codeguru-profiler-java-agent-standalone-1.2.4.jar

Remove local directories

🙏

Thanks

for

Watching

Amazon CodeGuru - Hands-On Demo

By Deepak Dubey

Amazon CodeGuru - Hands-On Demo

Amazon CodeGuru - Hands-On Demo

  • 68