Skip to content

Commit

Permalink
updating grafana tempo nodejs examples
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Aug 13, 2024
1 parent 1374b81 commit 131bff1
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 475 deletions.

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions examples/quick-start-grafana-cloud-tempo-nodejs/.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
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>"

# 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>"
1 change: 1 addition & 0 deletions examples/quick-start-grafana-cloud-tempo-nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.DS_Store
.env
/resources/datastore.yaml
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"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@ receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

processors:
batch:
timeout: 100ms

exporters:
logging:
verbosity: detailed
loglevel: debug
otlp:
endpoint: tempo-us-central1.grafana.net:443
headers:
authorization: Basic <base64 encoded username:password>
authorization: Basic ${env:GRAFANA_AUTH_WRITE_HASH}
# https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging, otlp]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,66 @@
version: '3'
version: "3"

services:
app:
image: quick-start-nodejs
build: .
ports:
- "8080:8080"
depends_on:
otel-collector:
condition: service_started

otel-collector:
image: otel/opentelemetry-collector-contrib:0.105.0
command:
- "--config"
- "/otel-local-config.yaml"
environment:
- GRAFANA_AUTH_WRITE_HASH
volumes:
- ./collector.config.yaml:/otel-local-config.yaml

# Cloud-based Managed Tracetest
tracetest-agent:
image: kubeshop/tracetest-agent:latest
environment:
# Get the required information here: https://app.tracetest.io/retrieve-token
- TRACETEST_API_KEY=${TRACETEST_TOKEN}
- TRACETEST_ENVIRONMENT_ID=${TRACETEST_ENVIRONMENT_ID}

tracetest-apply:
build:
dockerfile: Dockerfile.tracetest
volumes:
- ./resources:/resources
environment:
TRACETEST_TOKEN: ${TRACETEST_TOKEN}
TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID}
GRAFANA_AUTH_READ_HASH: ${GRAFANA_AUTH_READ_HASH}
entrypoint:
- bash
- /resources/apply.sh
networks:
default: null
depends_on:
app:
condition: service_started
tracetest-agent:
condition: service_started

tracetest-run:
build:
dockerfile: Dockerfile.tracetest
volumes:
- ./resources:/resources
environment:
TRACETEST_TOKEN: ${TRACETEST_TOKEN}
TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID}
entrypoint:
- bash
- /resources/run.sh
networks:
default: null
depends_on:
tracetest-apply:
condition: service_completed_successfully
32 changes: 32 additions & 0 deletions examples/quick-start-grafana-cloud-tempo-nodejs/resources/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID
GRAFANA_HASH=$GRAFANA_AUTH_READ_HASH

apply() {
echo "Configuring TraceTest"
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID

echo "Applying Resources"
echo "
type: DataStore
spec:
id: current
name: Grafana Tempo Cloud
type: tempo
tempo:
type: http
http:
url: https://tempo-us-central1.grafana.net/tempo
headers:
Authorization: Basic ${GRAFANA_HASH}
" > /resources/datastore.yaml

tracetest apply datastore -f /resources/datastore.yaml
tracetest apply test -f /resources/test.yaml
}

apply
16 changes: 16 additions & 0 deletions examples/quick-start-grafana-cloud-tempo-nodejs/resources/run.sh
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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:

# Grafana
otel-collector:
image: otel/opentelemetry-collector-contrib:0.59.0
image: otel/opentelemetry-collector-contrib:0.100.0
command:
- "--config"
- "/otel-local-config.yaml"
Expand Down

0 comments on commit 131bff1

Please sign in to comment.