Skip to content

Apodini/CollectorAnalystPresenterExample

Repository files navigation

Collector, Analyst, and Presenter Example System

DOI codecov Build and Test Build Docker Compose

This repository contains an example system consitig of three web services that highlights the usage of Collector, Analyst, and Presenter in combination with the Apodini framework using ApodiniCollector and ApodiniAnalystPresenter. It features a database web service, a processing web service, and a gateway that offers the public API of the web service. All web services collect metrics and traces using the Collector framework. A client application allows developers to observe inisights generated using Analyst and pesented using Presenter:

Screenshot of the client application showing the connect screen. The connect screen shows a text field to enter the hostname of the system and a button to start connecting to the Presenter endpoint Screenshot of the main screen that allows developers to observe the system. It shows three sections that a developer can tap on to display more information about the three deployed web services.

Run the Example System

You can start the web services on any system that supports docker and docker compose. Follow the instructions on https://docs.docker.com/compose/install/ to install docker and docker compose.
Xcode 13 (only available on macOS) is required to build and run the example client application. Follow the instructions on https://developer.apple.com/xcode/ to install the latest version of Xcode.

  1. Start the web services by running the $ docker compose up command in the root of the repository. It compiles and starts up all three web services as well as adjacently deployed Jaeger and Prometheus instances.
  2. You can now interact with the API using your favorite tool to explore RESTful APIs. The section System Functionality includes a detailed description of the API endpoints.
  3. Start the client application by opening the Example.xcodeproj in the Client folder. Once the project you can start the application by following the instructions on Running Your App in the Simulator or on a Device

System Functionality

The system can collect locations shared by users and generates hotspots indicating frequently visited places. Please note that this is a demo system and does not include any authentication or authorization mechanisms.

Create a new location entry:

POST at /v1/user/{userID}/location, e.g. http://localhost/v1/user/1/location with a payload encoded in JSON (header Content-Type set to application/json) that encodes a location: {"latitude": 0.0, "longitude": 0.0}`.
You can try out the following curl command to set a request to the gateway:

curl --header "Content-Type: application/json" \
     --request POST \
     --data '{"latitude": 42.0, "longitude": 24.0}' \
     http://localhost/v1/user/1/locations

Get hotspots

GET at /v1/user/{userID}/hotspots, e.g. http://localhost/v1/user/1/hotspots that returns the calculated hotspots.
You can try out the following curl command to get a list of hotspots:

curl http://localhost/v1/user/1/hotspots

Metrics and Presenter Handler

In addition, the gateway includes a /v1/metrics endpoint to deliver metrics information to Prometheus and a /v1/metrics-ui endpoint that delivers the Presenter UI to the client application.

Development Setup

To easily continue developing the example system, you can open the Example.xcworkspace found at the root of the repo using Xcode. The workspace bundles all three web services and the client application. You can run and build the client application and web services as described in Running Your App in the Simulator or on a Device by selecting the corresponding scheme.

To test the collection of metrics and traces, you can run the $ docker compose -f docker-compose-development.yml up command in the root of the repo start-up adjacently deployed Jaeger and Prometheus instances used by the web services. All web services are configured to connect to the instances started using the $ docker compose -f docker-compose-development.yml up command.

To test the setup defined in docker-compose.yml setup you can run the $ docker compose -f docker-compose-locally.yml up to build all files locally using the source code in this repository while using the same setup as defined in docker-compose.yml.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

License

This project is licensed under the MIT License. See License for more information.

About

An Example for the usage of Collector, Analyst, and Presenter

Resources

Code of conduct

Stars

Watchers

Forks

Packages