Skip to content

Commit

Permalink
chore(docs/examples): Updating Tempo X Node.js (#3960)
Browse files Browse the repository at this point in the history
* chore(docs/examples): Updating Tempo X Node.js

* updating pokeshop grafana tempo example/recipe

* updating pokeshop grafana tempo example/recipe

* updating grafana tempo nodejs examples

* updating grafana cloud tempo pokeshop

* PR suggestions updates
  • Loading branch information
xoscar authored Aug 14, 2024
1 parent 6e3915b commit 298aef1
Show file tree
Hide file tree
Showing 57 changed files with 719 additions and 1,422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ This is a simple quick start guide on how to configure a fully instrumented API
**Tracetest Account**:

- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs.
- Create an [environment](/concepts/environments).
- Create an [environment token](/concepts/environment-tokens).
- Have access to the environment's [agent API key](/configuration/agent).
- Have access to the environment's [agent API key](https://app.tracetest.io/retrieve-token).

**Grafana Cloud Account**

Expand All @@ -64,11 +62,10 @@ cd tracetest/examples/tracetest-grafana-cloud-tempo-pokeshop
Follow these instructions to run the quick start:

1. Copy the `.env.template` file to `.env`.
2. Log into the [Tracetest app](https://app.tracetest.io/).
3. Fill out the [token](https://docs.tracetest.io/concepts/environment-tokens) and [API key](https://docs.tracetest.io/concepts/agent) details by editing your `.env` file. You can find these values in the Settings area for your environment.
4. Run `docker compose up -d`.
5. This example is configured to use the Grafana Tempo Tracing Backend. Ensure the environment you're using to run this example is configured to use the Grafana Tempo Tracing Backend by clicking on Settings, Tracing Backend, Grafana Tempo, Save. Or, use the CLI as explained below.
6. Run tests from the Tracetest Web UI by accessing the app with the URL `http://demo-api:8081/pokemon/import`.
2. Fill out the [TRACETEST_TOKEN and ENVIRONMENT_ID](https://app.tracetest.io/retrieve-token) details by editing your `.env` file.
3. Fill out the [GRAFANA_AUTH_READ_HASH and GRAFANA_AUTH_WRITE_HASH](https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/) deatails from your Tempo setup.
3. Run `docker compose run tracetest-run`.
4. Follow the links in the output to view the test results.

Follow along with the sections below for an in detail breakdown of what the example you just ran did and how it works.

Expand All @@ -89,91 +86,34 @@ This is a [fragment from the main tracing file](https://github.com/kubeshop/poke
Configure the `.env` like shown below.

```bash
TRACETEST_API_KEY="<YOUR_TRACETEST_API_KEY>"
TRACETEST_API_TOKEN="<YOUR_TRACETEST_TOKEN>"
```

## Configuring OpenTelemetry Collector

Configure OpenTelemetry Collector to send traces to Grafana Cloud Tempo.

```yaml title="collector.config.yaml"
receivers:
otlp:
protocols:
grpc:
http:

exporters:
logging:
verbosity: detailed
otlp:
endpoint: tempo-us-central1.grafana.net:443
headers:
authorization: Basic <base64 encoded username:password>

service:
pipelines:
traces:
receivers: [otlp]
exporters: [logging, otlp]
```
Fill the authorization header in the `collector.config.yaml` file from your Grafana Tempo Setup. It should be encoded `base64` with the format of `username:token`. Follow [this guide to learn how](https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/).

## Configuring Grafana Tempo
# Get the required information here: https://app.tracetest.io/retrieve-token

Configure Tempo as a Tracing Backend:
TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>"

```yaml title="tracetest-tracing-backend.yaml"
---
type: DataStore
spec:
id: tempo-cloud
name: Tempo
type: tempo
tempo:
type: http
http:
url: https://tempo-us-central1.grafana.net/tempo
headers:
authorization: Basic <base64 encoded username:password>
tls: {}
```

Fill in the details of your Grafana Cloud Tempo instance by using the HTTP integration `authorization` header. It should be encoded `base64` with the format of `username:token`. Follow [this guide to learn how](https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/).

```bash
tracetest config -t <YOUR_API_TOKEN>
tracetest apply datastore -f ./tracetest-tracing-backend.yaml
# https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/
GRAFANA_AUTH_READ_HASH="<YOUR_GRAFANA_AUTH_READ_HASH>"
GRAFANA_AUTH_WRITE_HASH="<YOUR_GRAFANA_AUTH_WRITE_HASH>"
```

## Run the Pokeshop Demo App, OpenTelemetry Collector, and Tracetest Agent with Docker Compose

The [`docker-compose.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/tracetest-grafana-cloud-tempo-pokeshop/docker-compose.yml) in the root directory contains the Pokeshop Demo app services.

The [`docker-compose.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/tracetest-grafana-cloud-tempo-pokeshop/docker-compose.yml) also contains the Tracetest Agent and OpenTelemetry Collector.

To start it, run this command:

```bash
docker compose up -d
```

This will start the Pokeshop Demo app, OpenTelemetry Collector, and Tracetest Agent.

## Run Tracetest Tests

1. Open [Tracetest](https://app.tracetest.io/)
2. [Configure Grafana Tempo as a tracing backend](/configuration/connecting-to-data-stores/tempo) if you have not already as explained above.
3. Start creating tests! Make sure to use the `http://demo-api:8081/pokemon/import` URL in your test creation.
4. To trigger tests in the CLI, first [install the CLI](/cli/cli-installation-reference), [configure it](/cli/configuring-your-cli), and [run a test](/cli/running-tests). From the root of the quick start directory, run:
### Run Tracetest Tests

```bash
tracetest configure -t <YOUR_API_TOKEN>
tracetest run test -f ./tests/test.yaml
docker compose run tracetest-run
```

This will:
1. Start the Node.js app, the OpenTelemetry Collector, and send the traces to Tempo.
2. Start the Tracetest Agent.
3. Configure the tracing backend and create tests in your environment.
4. Run the tests.

## Learn More

Feel free to check out our [examples in GitHub](https://github.com/kubeshop/tracetest/tree/main/examples) and join our [Slack Community](https://dub.sh/tracetest-community) for more info!
Loading

0 comments on commit 298aef1

Please sign in to comment.