Skip to content

elastic/android-agent-demo

Repository files navigation

Demo application

To showcase an end-to-end scenario including distributed tracing we'll instrument this demo weather application that comprises two Android UI fragments and a simple local backend service based on Spring Boot.

Components

components

Backend service

Located in the backend module. This is a simple local backend service based on Spring Boot that provides APIs for the application and helps showcasing the the distributed tracing use case.

Android application

Located in the app module. The first screen will have a dropdown list with some city names and also a button that takes you to the second one, where you’ll see the selected city’s current temperature. If you pick a non-European city on the first screen, you’ll get an error from the (local) backend when you head to the second screen. This is to demonstrate how network and backend errors are captured and correlated.

EDOT Collector

It collects telemetry from both the application and backend service and stores it in Elasticsearch. The edot-collector module in this project is a helper tool that takes care of setting up an EDOT Collector for testing purposes. Refer to the EDOT Collector docs for more information.

How to run

Prerequisites

  • Java 17 or higher.
  • An Elasticsearch + Kibana setup with version 8.19.0 or higher. If you don't have one yet, you can quickly create it with start-local.
  • An Elasticsearch API Key. Take a look at how to create one here.
  • An Android emulator.

Note

The reason why is recommended using an emulator is because the endpoints set here and here point to local services via the emulator's localhost IP (10.0.2.2). If you wanted to use a real device, you'd need to replace the 10.0.2.2 host by the one of the machine where you'll start the services mentioned in the steps below.

Step 1: Setting your Elasticsearch properties

You must set your Elasticsearch endpoint URL and API Key into the elasticsearch.properties file.

endpoint=YOUR_ELASTICSEARCH_ENDPOINT
api_key=YOUR_ELASTICSEARCH_API_KEY

Replace YOUR_ELASTICSEARCH_ENDPOINT and YOUR_ELASTICSEARCH_API_KEY with the respective values.

Step 2: Launching the EDOT Collector

We're going to use the edot-collector-launcher script, which will:

Once the EDOT Collector is running, its endpoint will be http://localhost:4318.

You don't need to set it for this demo application, as it has already been done here. So, for this demo application use case, once the EDOT Collector is running, you're ready to go to the next step.

For Windows

Execute the edot-collector-launcher.ps1 script with PowerShell. You can learn how to do so by taking a look at this guide.

For Linux and MacOS

Execute the edot-collector-launcher script. You can do so by opening up a terminal, navigating to this directory and running the following command:

./edot-collector-launcher

Step 3: Launching the backend service

We're going to use the backend-launcher script, which will build and run the Spring Boot backend service.

Once the backend service is running, its endpoint will be http://localhost:8080/v1/.

You don't need to set it for this demo application, as it has already been done here. So, for this demo application use case, once the backend service is running, you're ready to go to the next step.

For Windows

Execute the backend-launcher.ps1 script with PowerShell. You can learn how to do so by taking a look at this guide.

For Linux and MacOS

Execute the backend-launcher script. You can do so by opening up a terminal, navigating to this directory and running the following command:

./backend-launcher

Step 4: Launch the Android application

Open up this project with Android Studio and run the application in an Android Emulator. Once everything is running, navigate around in the app to generate some load that we would like to observe in Elastic APM. So, select a city, click Next and repeat it multiple times. Please, also make sure to select New York at least once. You will see that the weather forecast won’t work for New York as the city.

Analyzing the data

After launching the app and navigating through it, you should be able to start seeing telemetry data coming into your configured Kibana instance. For a more detailed overview, take a look at how to Visualize telemetry in the docs.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published