-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(examples/docs): Updating jaeger x node.js example to be the initial template #3958
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -43,9 +43,7 @@ This is a simple quick start on how to configure a Node.js app to use OpenTeleme | |||||
**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). | ||||||
|
||||||
**Docker**: Have [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine. | ||||||
|
||||||
|
@@ -64,10 +62,9 @@ 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 -f ./docker-compose.yaml -f ./docker-compose.agent.yaml up -d`. | ||||||
5. This example is configured to use the Jaeger Tracing Backend. Ensure the environment you're using to run this example is configured to use the Jaeger Tracing Backend by clicking on Settings, Tracing Backend, Jaeger, Save. Or, use the CLI as explained below. | ||||||
6. Run tests from the Tracetest Web UI by accessing the app with the URL `http://app:8080/`. | ||||||
3. Fill out the [token](https://app.tracetest.io/retrieve-token) details by editing your `.env` file. | ||||||
4. Run `docker compose run tracetest-run`. | ||||||
5. 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. | ||||||
|
||||||
|
@@ -84,12 +81,15 @@ The Node.js app is a simple Express app, contained in [the `app.js` file](https: | |||||
Configure the `.env` like shown below. | ||||||
|
||||||
```bash | ||||||
TRACETEST_API_KEY="<YOUR_TRACETEST_API_KEY>" | ||||||
# Get the required information here: https://app.tracetest.io/retrieve-token | ||||||
|
||||||
TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>" | ||||||
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>" | ||||||
``` | ||||||
|
||||||
The OpenTelemetry tracing is contained in the `tracing.otel.grpc.js` or `tracing.otel.http.js` files. Traces will be sent to Tracetest Agent. | ||||||
|
||||||
Choosing [the `tracing.otel.grpc.js` file](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/tracing.otel.grpc.js) will send traces to OpenTelemetry Collector's `GRPC` endpoint. | ||||||
Choosing the [`tracing.otel.grpc.js` file](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/tracing.otel.grpc.js) will send traces to OpenTelemetry Collector's `GRPC` endpoint. | ||||||
|
||||||
Enabling the tracer is done by preloading the trace file. As seen in the `package.json`. | ||||||
|
||||||
|
@@ -99,55 +99,23 @@ Enabling the tracer is done by preloading the trace file. As seen in the `packag | |||||
}, | ||||||
``` | ||||||
|
||||||
## Configuring Jaeger | ||||||
|
||||||
Configure Jaeger as a Tracing Backend: | ||||||
|
||||||
```yaml title=tracetest-tracing-backend.yaml | ||||||
--- | ||||||
type: DataStore | ||||||
spec: | ||||||
name: Jaeger | ||||||
type: jaeger | ||||||
default: true | ||||||
jaeger: | ||||||
endpoint: jaeger:16685 | ||||||
tls: | ||||||
insecure: true | ||||||
``` | ||||||
|
||||||
```bash | ||||||
tracetest config -t <YOUR_API_TOKEN> | ||||||
tracetest apply datastore -f ./tracetest-tracing-backend.yaml | ||||||
``` | ||||||
|
||||||
## Run the Node.js App, Jaeger and OpenTelemetry Collector with Docker Compose | ||||||
|
||||||
The [`docker-compose.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/docker-compose.yaml) and [`Dockerfile`](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/Dockerfile) in the root directory are for the Node.js app. The `docker-compose.yaml` contains one service for the Node.js app. | ||||||
|
||||||
The [`docker-compose.agent.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/docker-compose.agent.yaml) is for the Tracetest Agent, Jaeger, and OpenTelemetry Collector. | ||||||
The [`docker-compose.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/docker-compose.yaml) and [`Dockerfile`](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/Dockerfile) in the root directory are for the Node.js app. The `docker-compose.yaml` contains one service for the Node.js app, as well as the Tracetest Agent, Jaeger, and OpenTelemetry Collector. | ||||||
|
||||||
[The `collector.config.yaml` configures the OpenTelemetry Collector](https://github.com/kubeshop/tracetest/blob/main/examples/quick-start-jaeger-nodejs/collector.config.yaml). It receives traces via either `grpc` or `http`. Then, exports them to Jaeger via the OTLP `exporter`. | ||||||
|
||||||
To start it, run this command: | ||||||
|
||||||
```bash | ||||||
docker compose -f ./docker-compose.yaml -f ./docker-compose.agent.yaml up -d | ||||||
docker compose run tracetest-run | ||||||
``` | ||||||
|
||||||
This will start the Node.js app the OpenTelemetry Collector and send the traces to Jaeger. | ||||||
|
||||||
## Run Tracetest Tests | ||||||
|
||||||
1. Open [Tracetest](https://app.tracetest.io/) | ||||||
2. [Configure Jaeger as a tracing backend](/configuration/connecting-to-data-stores/jaeger) if you have not already as explained above. | ||||||
3. Start creating tests! Make sure to use the `http://app:8080/` 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: | ||||||
|
||||||
```bash | ||||||
tracetest configure -t <YOUR_API_TOKEN> | ||||||
tracetest run test -f ./test-api.yaml | ||||||
``` | ||||||
This will: | ||||||
1. Start the Node.js app the OpenTelemetry Collector and send the traces to Jaeger. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
2. Start the Tracetest Agent. | ||||||
3. Configure the tracing backend and create the Tests in your environment. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
4. Run the tests. | ||||||
|
||||||
```mdx-code-block | ||||||
</TabItem> | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
TRACETEST_API_KEY="<YOUR_TRACETEST_API_KEY>" | ||
TRACETEST_API_TOKEN="<YOUR_TRACETEST_TOKEN>" | ||
# Get the required information here: https://app.tracetest.io/retrieve-token | ||
|
||
TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>" | ||
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM alpine | ||
|
||
WORKDIR /app | ||
ARG TRACETEST_IMAGE_VERSION=v1.4.0 | ||
|
||
RUN apk --update add bash jq curl | ||
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION | ||
|
||
WORKDIR /resources | ||
|
||
ENTRYPOINT ["echo", "Tracetest CLI installed"] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
TOKEN=$TRACETEST_TOKEN | ||
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID | ||
|
||
apply() { | ||
echo "Configuring TraceTest" | ||
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID | ||
|
||
echo "Applying Resources" | ||
tracetest apply datastore -f /resources/datastore.yaml | ||
tracetest apply test -f /resources/test.yaml | ||
} | ||
|
||
apply |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type: DataStore | ||
spec: | ||
id: current | ||
name: jaeger | ||
type: jaeger | ||
default: true | ||
jaeger: | ||
endpoint: jaeger:16685 | ||
headers: | ||
"": "" | ||
tls: | ||
insecure: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
TOKEN=$TRACETEST_TOKEN | ||
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID | ||
|
||
run() { | ||
echo "Configuring Tracetest" | ||
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID | ||
|
||
echo "Running Trace-Based Tests..." | ||
tracetest run test -f /resources/test.yaml | ||
} | ||
|
||
run |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.