quickpizza

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2023 License: Apache-2.0

README ΒΆ

QuickPizza

QuickPizza screenshot

What is QuickPizza? πŸ•πŸ•πŸ•

QuickPizza is a web application, used for demonstrations and workshops, that generates new and exciting pizza combinations!

The app is built using SvelteKit for the frontend and Go for the backend.

The tests written for QuickPizza demonstrates the basic and advanced functionalities of k6, ranging from a basic load test to using different modules and extensions.

Requirements

Run locally with Docker

To run the app locally with Docker, run the command:

docker run --rm -it -p 3333:3333  ghcr.io/grafana/QuickPizza-local:latest

or build image from the repo:

docker run --rm -it -p 3333:3333 $(docker build -q .)

That's it!

Now you can go to localhost:3333 and get some pizza recommendations!

Use k6 to test QuickPizza

All tests live in the k6 folder. Within this folder, you will find the following folders:

  • foundations - covers the basic functionalities of k6.
  • browser - covers a more deep-dive look on how to use the k6 browser module for browser and web performance testing.
  • disruptor - covers a more deep-dive look on how to use xk6-disruptor for failure injection testing.
  • advanced - covers tests that are more advanced such as hybrid tests, tracing, etc.

To run tests on the foundations folder, you can use the following commands:

cd k6/foundations
k6 run 01.basic.js

If you want to run one iteration with one virtual user, you can use the following command:

k6 run --iterations 1 --vus 1 01.basic.js

If QuickPizza is deployed remotely, then pass the hostname and port through the BASE_URL environment variable as follows:

k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js

If the test uses an extension, you need to build it first via xk6. To build the extension using Docker, you can run the following command:

cd k6/foundations/extension

docker run --rm -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
  grafana/xk6 build  \
  --with xk6-internal=.

Note that the GOOS variable is for Mac. Please refer to Build a k6 binary using Docker for more information.

To run the test that uses an extension, you can run the following command:

./extension/k6 run 11.extension.js

Collect telemetry

Testing something you can't observe is only half the fun. QuickPizza is instrumented using best practices to record logs, emit metrics, traces and allow profiling. You can either collect and store this data locally or send it to Grafana Cloud.

Local Setup

The docker-compose-local.yaml file is set up to run and orchestrate the QuickPizza, Grafana, Tempo, Prometheus, Pyroscope, and Grafana Agent containers.

The Grafana Agent collects observability data from the QuickPizza app and forwards it to the Tempo, Prometheus, and Pyroscope services. Then, you can visualize and correlate the data with a local running Grafana instance.

To start the local environment, use the following command:

docker compose -f docker-compose-local.yaml up -d --build

Like before, QuickPizza is available at localhost:3333. It's time to discover some fancy pizzas!

Then, you can visit the Grafana instance running at localhost:3000 to access QuickPizza data.

Pyroscope Data Source

Please refer to agent-local.river to find the labels applied to the telemetry data.

Grafana Cloud

The docker-compose-cloud.yaml file is set up to run the QuickPizza and Grafana Agent containers.

In this setup, the Grafana Agent collects observability data from the QuickPizza app and forwards it to Grafana Cloud.

You will need the following settings:

  1. The name of the Grafana Cloud Stack where the telemetry data will be stored.
  2. An Access Policy Token that includes the following scopes for the selected Grafana Cloud Stack: stacks:read, metrics:write, logs:write, traces:write, and profiles:write.

Then, create an .env file with the following environment variables and the values of the previous settings:

GRAFANA_CLOUD_STACK=
GRAFANA_CLOUD_TOKEN=

Finally, execute the Docker Compose command using the docker-compose-cloud.yaml file as before:

docker compose -f docker-compose-cloud.yaml up -d --build

QuickPizza is available at localhost:3333. Click the Pizza, Please! button and discover some awesome pizzas!

Now, you can log in to Grafana Cloud and explore QuickPizza's telemetry data on the Prometheus, Tempo, and Pyroscope instances of your Grafana Cloud Stack. Refer to agent-cloud.river to find the labels applied to the telemetry data.

Enable Frontend observability (Grafana Faro)

Frontend observability is available exclusively in Grafana Cloud. To enable Grafana Cloud Frontend Observability for QuickPizza, add the QuickPizza_CONF_FARO_URL variable to the .env file, setting its value to your Faro web URL:

QuickPizza_CONF_FARO_URL=

Restart the docker-compose-cloud.yaml environment.

Frontend Observability

Deploy QuickPizza Docker image

The Dockerfile contains the setup for running QuickPizza without collecting data with the Grafana agent.

You can use the Dockerfile or build a Docker image to deploy the QuickPizza app on any cloud provider that supports Docker deployments. For simplicity, here are the Fly.io instructions:

  1. Authenticate using the fly CLI.
  2. Then, run the CLI to deploy the application and set up the internal port 3333 that the server listens to.
    fly launch --internal-port 3333 --now
    

For deployments on remote servers, you need to pass the BASE_URL environment variable when running the k6 tests as follows:

k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js

Deploy application to Kubernetes

If you want to run a test that uses xk6-disruptor, or want to experiment with distributed tracing, you will need to deploy QuickPizza to Kubernetes.

For a detailed setup instructions, see the QuickPizza Kubernetes guide.

Directories ΒΆ

Path Synopsis
pkg
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL