Skip to content

Commit

Permalink
WMS ID 11742 - Configure a Java application to send traces to Oracle …
Browse files Browse the repository at this point in the history
…Cloud Infrastructure (OCI) APM Tracing with the Graal Development Kit for Micronaut (GDK) and WMS ID 11745 - Publish standard and custom metrics to Oracle Cloud Infrastructure (OCI) Monitoring with the Graal Development Kit for Micronaut (GDK) (#423)

* Add gdk-oci-tracing

* Add gdk-oci-metrics

* minor change
  • Loading branch information
LesiaChaban authored Oct 7, 2024
1 parent 062ff0f commit c455f23
Show file tree
Hide file tree
Showing 68 changed files with 2,534 additions and 0 deletions.
59 changes: 59 additions & 0 deletions gdk-oci-metrics/00-introduction/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Introduction

## About this Workshop

This workshop takes you step by step through the process of building a Java application to Publish standard and custom metrics to Oracle Cloud Infrastructure (OCI) Monitoring with the Graal Development Kit for Micronaut (GDK). It shows you how to query and visualize the published metrics using the OCI Metrics Explorer. You'll use GraalVM Native Image to package and run the application as a native executable.

It is aimed at application developers and DevOps engineers with a basic knowledge of Java.

Estimated Workshop Time: 75 minutes

### What is Graal Development Kit for Micronaut?

The [Graal Development Kit for Micronaut (GDK)](https://graal.cloud/gdk) is an Oracle build of the open source Micronaut® framework. The GDK provides a curated set of Micronaut framework modules that simplify cloud application development, are designed for ahead-of-time compilation with GraalVM Native Image, and are fully supported by Oracle. The GDK also provides project creation utilities, VS Code and IntelliJ extensions to simplify application development and deployment.

### What is Micronaut?

The [Micronaut® framework](https://micronaut.io/) is a modern, JVM-based framework to build modular, easily testable microservice and serverless applications. By avoiding runtime reflection in favor of annotation processing, Micronaut improves the Java-based development experience by detecting errors at compile time instead of runtime, and improves Java-based application startup time and memory footprint. Micronaut includes a persistence framework called Micronaut Data that precomputes your SQL queries at compilation time making it a great fit for working with databases like MySQL, Oracle Autonomous Database, etc.

> Micronaut® is a registered trademark of Object Computing, Inc. Use is for referential purposes and does not imply any endorsement or affiliation with any third-party product.
### What is GraalVM Native Image?

[GraalVM Native Image](https://www.graalvm.org/) technology compiles Java applications ahead-of-time into self-contained native executables that are small in size, start almost instantaneously, provide peak performance with no warmup, and require less memory and CPU. Only the code that is required at run time by the application gets added into the executable file. Native Image is perfect for containerized workloads and microservices — which is why it has been embraced by Micronaut, Spring Boot, Helidon, and Quarkus.

The GDK modules are designed for ahead-of-time compilation with GraalVM Native Image to produce native executables that are ideal for microservices: they have a small memory footprint, start instantly, and provide peak performance with no warmup.

> Graal Development Kit for Micronaut, and Oracle GraalVM are available at no additional cost on Oracle Cloud Infrastructure (OCI).
### Objectives

In this workshop, you will:

* Use Visual Studio Code (VS Code) from a remote desktop running in an OCI Compute Instance
* Review the application source code developed with the Graal Development Kit for Micronaut
* Configure the application to use OCI Monitoring
* Build a native executable for the application using GraalVM Native Image
* Run the application and publish standard and custom metrics to OCI Monitoring
* View the published metrics in OCI Monitoring

### Prerequisites

This workshop assumes you have:

* Some familiarity with Oracle Cloud Infrastructure (OCI)
* Understanding of the Java programming language
* Oracle GraalVM for JDK 17
* Visual Studio Code (VS Code)
* A browser with access to the internet
* An Oracle Cloud Infrastructure (OCI) account with adequate permissions

## Learn More

* [Graal Development Kit for Micronaut](https://graal.cloud/gdk/)

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
85 changes: 85 additions & 0 deletions gdk-oci-metrics/01-prepare-setup/prepare-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Prepare Setup

## Introduction

This lab will show you how to download the Oracle Resource Manager (ORM) stack zip file needed to set up the resources needed to run this workshop.

*Estimated Lab Time:* 5 minutes

### Objectives

* Download ORM stack
* (*Optional*) Configure an existing Virtual Cloud Network (VCN)
* Select a Compartment for the workshop

### Prerequisites

This lab assumes you have:

* An Oracle Cloud account

## Task 1: Download Oracle Resource Manager (ORM) stack zip file

1. Click on the link below to download the Resource Manager zip file you need to build your environment:

* [gdk-oci-metrics-ll-orm.zip](https://c4u04.objectstorage.us-ashburn-1.oci.customer-oci.com/p/EcTjWk2IuZPZeNnD_fYMcgUhdNDIDA6rt9gaFj_WZMiL7VvxPBNMY60837hu5hga/n/c4u04/b/livelabsfiles/o/oci-library/gdk-oci-metrics-ll-orm.zip)

2. Save it in your downloads folder.

3. (*Recommended*) We strongly recommend using this stack to create a new self-contained/dedicated VCN along with your instance. Skip to **Task 3** to follow the recommendation.

4. Alternatively, if you would rather use an existing VCN then proceed to the next task to update your existing VCN with the required network security rules.

## Task 2: Add Network Security Rules to an Existing VCN

This workshop requires a certain number of ports to be available, a requirement that is automatically met by using the default ORM stack execution that creates a new dedicated VCN.

However, if you would rather use an existing VCN/subnet, follow these steps to add the following rules to the network security list.

1. From the Oracle Cloud Console navigation menu, go to **Networking >> Virtual Cloud Networks**.
2. Choose your network.
3. Under **Resources**, select **Security Lists**.
4. Click on **Default Security Lists** under the **Create Security List** button.
5. Click **Add Ingress Rules** button.
6. Create a rule for each row in the *Ingress* table below:

| Stateless | Source Type | Source CIDR | IP Protocol | Source Port Range | Destination Port Range | Description |
| :------------- | :---------: | :---------: | :---------: | :---------------: | :--------------------: | :------------------------- |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Remote Desktop using noVNC |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 6080 | Remote Desktop using noVNC |
{: title="Network Ingress Security Rules"}

7. Select **Egress Rule** from the left panel.
8. Click **Add Egress Rule** button
9. Create a rule for each row in the *Egress* table below:

| Stateless | Source Type | Destination CIDR | IP Protocol | Source Port Range | Destination Port Range | Description |
| :------------- | :---------: | :--------------: | :---------: | :---------------: | :--------------------: | :-------------------- |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Outbound HTTP access |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 443 | Outbound HTTPS access |
{: title="Network Egress Security Rules"}

## Task 3: Select a Compartment for the Workshop

We recommend you use a single compartment for the workshop. We will refer to this as your workshop compartment. This is the compartment where you will provision all the resources - Oracle Resource Manager (ORM) Stack, Compute Instance, VCN/Subnet - needed for the workshop.

1. From the Oracle Cloud Console navigation menu, go to **Identity & Security >> Identity >> Compartments**.
2. Go to your workshop compartment.
3. Make a note of the compartment name and OCID. You will need this information in subsequent labs.

## Task 4: Setup Compute

Using the details from the above Tasks, proceed to the **Environment Setup** lab to set up your workshop environment using Oracle Resource Manager (ORM) with one of the following options:

* (*Recommended*) Create Stack: **Compute + Networking**
* Create Stack: **Compute only** with an existing VCN where security lists have been updated as per **Task 2** above

The ORM stack will provision a compute instance with 4 OCPUs, 64 GB RAM and a Remote Desktop environment.

You may now **proceed to the next lab**.

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
54 changes: 54 additions & 0 deletions gdk-oci-metrics/02-git-clone/git-clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Clone the Sample Application Source Code

## Introduction

This lab describes the steps to download the sample application source code used in the workshop.

Estimated Lab Time: 5 minutes

### Objectives

In this lab, you will:

* Clone the sample application source code

## Task 1: Clone the Sample Application Source Code

1. From the **Activities** menu, start a new **Terminal** window.

2. Clone the sample application source code.

```bash
<copy>
git init lab
cd lab
git remote add origin https://github.com/sachin-pikle/gdk-oci-samples.git
git config core.sparsecheckout true
echo "gdk-oci-metrics-mvn/*">>.git/info/sparse-checkout
git pull --depth=1 origin main
</copy>
```

3. Open the sample application source code from the _gdk-oci-metrics-mvn_ directory in **Visual Studio Code**.

```bash
<copy>
code gdk-oci-metrics-mvn
</copy>
```

4. VS Code may show a dialog box with the message "Do you trust the authors of the files in this folder?". Select **Trust the authors of all files in the parent folder 'oracle'** and click **Yes, I trust the authors**.

5. VS Code may ask you to choose a password for new keyring. Press **Cancel** twice to close the prompt.

6. VS Code may show a dialog box with the message "A git repository was found in the parent folders of the workspace or the open file(s). Would you like to open the repository?". Click **Never**.

![VS Code Question Icon](images/vs-code-question-icon.jpg#input)

You may now **proceed to the next lab**.

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c455f23

Please sign in to comment.