From 3b8bb2b9c9e5a94901446fd62c2f34c50c5c4a26 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:10:37 -0600 Subject: [PATCH 01/12] chore(examples): Updating vendor examples --- .../tracetest-tracing-backend.yaml | 11 --- .../{.env => .env.template} | 7 ++ examples/tracetest-lightstep/.gitignore | 1 + .../tracetest-lightstep/Dockerfile.tracetest | 11 +++ .../{tracetest => }/collector.config.yaml | 4 +- .../tracetest-lightstep/docker-compose.yaml | 73 ++++++++++++++++++- .../tracetest-lightstep/resources/apply.sh | 17 +++++ .../resources/datastore.yaml | 6 ++ examples/tracetest-lightstep/resources/run.sh | 16 ++++ .../{http-test.yaml => resources/test.yaml} | 0 .../tracetest/docker-compose.yaml | 50 ------------- .../tracetest/tracetest-config.yaml | 23 ------ .../tracetest/tracetest-provision.yaml | 17 ----- 13 files changed, 132 insertions(+), 104 deletions(-) delete mode 100644 examples/quick-start-jaeger-nodejs/tracetest-tracing-backend.yaml rename examples/tracetest-lightstep/{.env => .env.template} (87%) create mode 100644 examples/tracetest-lightstep/.gitignore create mode 100644 examples/tracetest-lightstep/Dockerfile.tracetest rename examples/tracetest-lightstep/{tracetest => }/collector.config.yaml (62%) create mode 100644 examples/tracetest-lightstep/resources/apply.sh create mode 100644 examples/tracetest-lightstep/resources/datastore.yaml create mode 100644 examples/tracetest-lightstep/resources/run.sh rename examples/tracetest-lightstep/{http-test.yaml => resources/test.yaml} (100%) delete mode 100644 examples/tracetest-lightstep/tracetest/docker-compose.yaml delete mode 100644 examples/tracetest-lightstep/tracetest/tracetest-config.yaml delete mode 100644 examples/tracetest-lightstep/tracetest/tracetest-provision.yaml diff --git a/examples/quick-start-jaeger-nodejs/tracetest-tracing-backend.yaml b/examples/quick-start-jaeger-nodejs/tracetest-tracing-backend.yaml deleted file mode 100644 index 1595add71d..0000000000 --- a/examples/quick-start-jaeger-nodejs/tracetest-tracing-backend.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -type: DataStore -spec: - id: current - name: Jaeger - type: jaeger - default: true - jaeger: - endpoint: jaeger:16685 - tls: - insecure: true diff --git a/examples/tracetest-lightstep/.env b/examples/tracetest-lightstep/.env.template similarity index 87% rename from examples/tracetest-lightstep/.env rename to examples/tracetest-lightstep/.env.template index 41d00e095f..9e93e0cab9 100644 --- a/examples/tracetest-lightstep/.env +++ b/examples/tracetest-lightstep/.env.template @@ -1,3 +1,10 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + +LIGHTSTEP_ACCESS_TOKEN="" + # Collector OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} diff --git a/examples/tracetest-lightstep/.gitignore b/examples/tracetest-lightstep/.gitignore new file mode 100644 index 0000000000..4c49bd78f1 --- /dev/null +++ b/examples/tracetest-lightstep/.gitignore @@ -0,0 +1 @@ +.env diff --git a/examples/tracetest-lightstep/Dockerfile.tracetest b/examples/tracetest-lightstep/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-lightstep/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-lightstep/tracetest/collector.config.yaml b/examples/tracetest-lightstep/collector.config.yaml similarity index 62% rename from examples/tracetest-lightstep/tracetest/collector.config.yaml rename to examples/tracetest-lightstep/collector.config.yaml index 1f00b60a81..37afd8469a 100644 --- a/examples/tracetest-lightstep/tracetest/collector.config.yaml +++ b/examples/tracetest-lightstep/collector.config.yaml @@ -13,14 +13,14 @@ exporters: logLevel: debug # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # OTLP for Lightstep otlp/lightstep: endpoint: ingest.lightstep.com:443 headers: - "lightstep-access-token": "" # Send traces to Lightstep. Read more in docs here: https://docs.lightstep.com/otel/otel-quick-start + "lightstep-access-token": ${env:LIGHTSTEP_ACCESS_TOKEN} # Send traces to Lightstep. Read more in docs here: https://docs.lightstep.com/otel/otel-quick-start service: pipelines: diff --git a/examples/tracetest-lightstep/docker-compose.yaml b/examples/tracetest-lightstep/docker-compose.yaml index b310d5094d..3f749beaa9 100644 --- a/examples/tracetest-lightstep/docker-compose.yaml +++ b/examples/tracetest-lightstep/docker-compose.yaml @@ -1,8 +1,52 @@ -# OpenTelemetry Demo +# OpenTelemetry Demo # https://github.com/open-telemetry/opentelemetry-demo version: "3.2" services: + # 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} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null + depends_on: + otel-frontend: + condition: service_healthy + 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 + cache: image: redis:6 restart: unless-stopped @@ -114,6 +158,11 @@ services: - otel-recommendationservice - otel-shippingservice - otel-collector + healthcheck: + test: ["CMD", "wget", "--spider", "localhost:8084"] + interval: 1s + timeout: 3s + retries: 60 # PaymentService otel-paymentservice: @@ -179,3 +228,25 @@ services: depends_on: postgres: condition: service_healthy + + postgres: + image: postgres:14 + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + healthcheck: + test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" + interval: 1s + timeout: 5s + retries: 60 + + otel-collector: + image: otel/opentelemetry-collector-contrib:0.68.0 + restart: unless-stopped + environment: + - LIGHTSTEP_ACCESS_TOKEN + command: + - "--config" + - "/otel-local-config.yaml" + volumes: + - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-lightstep/resources/apply.sh b/examples/tracetest-lightstep/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-lightstep/resources/apply.sh @@ -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 diff --git a/examples/tracetest-lightstep/resources/datastore.yaml b/examples/tracetest-lightstep/resources/datastore.yaml new file mode 100644 index 0000000000..8f546b0528 --- /dev/null +++ b/examples/tracetest-lightstep/resources/datastore.yaml @@ -0,0 +1,6 @@ +--- +type: DataStore +spec: + id: current + name: Lightstep + type: lightstep diff --git a/examples/tracetest-lightstep/resources/run.sh b/examples/tracetest-lightstep/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-lightstep/resources/run.sh @@ -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 diff --git a/examples/tracetest-lightstep/http-test.yaml b/examples/tracetest-lightstep/resources/test.yaml similarity index 100% rename from examples/tracetest-lightstep/http-test.yaml rename to examples/tracetest-lightstep/resources/test.yaml diff --git a/examples/tracetest-lightstep/tracetest/docker-compose.yaml b/examples/tracetest-lightstep/tracetest/docker-compose.yaml deleted file mode 100644 index 0e918b5fc9..0000000000 --- a/examples/tracetest-lightstep/tracetest/docker-compose.yaml +++ /dev/null @@ -1,50 +0,0 @@ -version: "3.2" -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-lightstep/tracetest/tracetest-config.yaml b/examples/tracetest-lightstep/tracetest/tracetest-config.yaml deleted file mode 100644 index f3116d864f..0000000000 --- a/examples/tracetest-lightstep/tracetest/tracetest-config.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-lightstep/tracetest/tracetest-provision.yaml b/examples/tracetest-lightstep/tracetest/tracetest-provision.yaml deleted file mode 100644 index 3ed599c3d6..0000000000 --- a/examples/tracetest-lightstep/tracetest/tracetest-provision.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -type: DataStore -spec: - name: Lightstep - type: lightstep - ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://otel-frontend:8084 - productCatalogEndpoint: otel-productcatalogservice:3550 - cartEndpoint: otel-cartservice:7070 - checkoutEndpoint: otel-checkoutservice:5050 From 07c20a51c38c8f8b69b1f1098bd3402c57ad1ad0 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:17:06 -0600 Subject: [PATCH 02/12] updating new relic example --- .../tracetest-lightstep/collector.config.yaml | 4 +- .../tracetest-lightstep/docker-compose.yaml | 2 +- examples/tracetest-new-relic/.env | 6 ++ .../tracetest-new-relic/docker-compose.yaml | 84 ++++++++++++++++++- examples/tracetest-new-relic/http-test.yaml | 26 ------ .../tracetest/collector.config.yaml | 36 -------- .../tracetest/docker-compose.yaml | 50 ----------- .../tracetest/tracetest-config.yaml | 22 ----- .../tracetest/tracetest-provision.yaml | 18 ---- 9 files changed, 91 insertions(+), 157 deletions(-) delete mode 100644 examples/tracetest-new-relic/http-test.yaml delete mode 100644 examples/tracetest-new-relic/tracetest/collector.config.yaml delete mode 100644 examples/tracetest-new-relic/tracetest/docker-compose.yaml delete mode 100644 examples/tracetest-new-relic/tracetest/tracetest-config.yaml delete mode 100644 examples/tracetest-new-relic/tracetest/tracetest-provision.yaml diff --git a/examples/tracetest-lightstep/collector.config.yaml b/examples/tracetest-lightstep/collector.config.yaml index 37afd8469a..49e79b46d3 100644 --- a/examples/tracetest-lightstep/collector.config.yaml +++ b/examples/tracetest-lightstep/collector.config.yaml @@ -9,8 +9,6 @@ processors: timeout: 100ms exporters: - logging: - logLevel: debug # OTLP for Tracetest otlp/tracetest: endpoint: tracetest-agent:4317 @@ -31,4 +29,4 @@ service: traces/lightstep: receivers: [otlp] processors: [batch] - exporters: [logging, otlp/lightstep] + exporters: [otlp/lightstep] diff --git a/examples/tracetest-lightstep/docker-compose.yaml b/examples/tracetest-lightstep/docker-compose.yaml index 3f749beaa9..6b036a304e 100644 --- a/examples/tracetest-lightstep/docker-compose.yaml +++ b/examples/tracetest-lightstep/docker-compose.yaml @@ -241,7 +241,7 @@ services: retries: 60 otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 + image: otel/opentelemetry-collector-contrib:0.100.0 restart: unless-stopped environment: - LIGHTSTEP_ACCESS_TOKEN diff --git a/examples/tracetest-new-relic/.env b/examples/tracetest-new-relic/.env index 41d00e095f..04ff7d7235 100644 --- a/examples/tracetest-new-relic/.env +++ b/examples/tracetest-new-relic/.env @@ -1,3 +1,9 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="MCiA34CIR" +TRACETEST_ENVIRONMENT_ID="ttenv_b42fa137465c6e04" +NEW_RELIC_INGEST_LICENSE="" + # Collector OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} diff --git a/examples/tracetest-new-relic/docker-compose.yaml b/examples/tracetest-new-relic/docker-compose.yaml index 2166ff2760..7b823455a9 100644 --- a/examples/tracetest-new-relic/docker-compose.yaml +++ b/examples/tracetest-new-relic/docker-compose.yaml @@ -1,8 +1,52 @@ -# OpenTelemetry Demo +# OpenTelemetry Demo # https://github.com/open-telemetry/opentelemetry-demo version: "3.2" services: + # 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} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null + depends_on: + otel-frontend: + condition: service_healthy + 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 + cache: image: redis:6 restart: unless-stopped @@ -15,6 +59,7 @@ services: # AdService otel-adservice: image: otel/demo:v0.3.4-alpha-adservice + platform: linux/amd64 environment: - AD_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT @@ -26,6 +71,7 @@ services: # CartService otel-cartservice: image: otel/demo:v0.3.4-alpha-cartservice + platform: linux/amd64 environment: - CART_SERVICE_PORT - REDIS_ADDR @@ -39,6 +85,7 @@ services: # CheckoutService otel-checkoutservice: image: otel/demo:v0.3.4-alpha-checkoutservice + platform: linux/amd64 environment: - CHECKOUT_SERVICE_PORT - CART_SERVICE_ADDR @@ -61,6 +108,7 @@ services: # CurrencyService otel-currencyservice: image: otel/demo:v0.3.4-alpha-currencyservice + platform: linux/amd64 environment: - CURRENCY_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT @@ -71,6 +119,7 @@ services: # EmailService otel-emailservice: image: otel/demo:v0.3.4-alpha-emailservice + platform: linux/amd64 environment: - APP_ENV=production - EMAIL_SERVICE_PORT @@ -82,6 +131,7 @@ services: # Frontend otel-frontend: image: otel/demo:v0.3.4-alpha-frontend + platform: linux/amd64 ports: - "${FRONTEND_PORT}:${FRONTEND_PORT}" environment: @@ -108,10 +158,16 @@ services: - otel-recommendationservice - otel-shippingservice - otel-collector + healthcheck: + test: ["CMD", "wget", "--spider", "localhost:8084"] + interval: 1s + timeout: 3s + retries: 60 # PaymentService otel-paymentservice: image: otel/demo:v0.3.4-alpha-paymentservice + platform: linux/amd64 environment: - PAYMENT_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT @@ -122,6 +178,7 @@ services: # ProductCatalogService otel-productcatalogservice: image: otel/demo:v0.3.4-alpha-productcatalogservice + platform: linux/amd64 environment: - PRODUCT_CATALOG_SERVICE_PORT - FEATURE_FLAG_GRPC_SERVICE_ADDR @@ -133,6 +190,7 @@ services: # RecommendationService otel-recommendationservice: image: otel/demo:v0.3.4-alpha-recommendationservice + platform: linux/amd64 depends_on: - otel-productcatalogservice - otel-collector @@ -146,6 +204,7 @@ services: # ShippingService otel-shippingservice: image: otel/demo:v0.3.4-alpha-shippingservice + platform: linux/amd64 environment: - SHIPPING_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT @@ -156,6 +215,7 @@ services: # FeatureFlagService otel-featureflagservice: image: otel/demo:v0.3.4-alpha-featureflagservice + platform: linux/amd64 ports: - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" # Feature Flag Service gRPC API environment: @@ -168,3 +228,25 @@ services: depends_on: postgres: condition: service_healthy + + postgres: + image: postgres:14 + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + healthcheck: + test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" + interval: 1s + timeout: 5s + retries: 60 + + otel-collector: + image: otel/opentelemetry-collector-contrib:0.100.0 + restart: unless-stopped + environment: + - NEW_RELIC_INGEST_LICENSE + command: + - "--config" + - "/otel-local-config.yaml" + volumes: + - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-new-relic/http-test.yaml b/examples/tracetest-new-relic/http-test.yaml deleted file mode 100644 index fc76274c5a..0000000000 --- a/examples/tracetest-new-relic/http-test.yaml +++ /dev/null @@ -1,26 +0,0 @@ -type: Test -spec: - id: YJmFC7hVg - name: Otel - List Products - description: Otel - List Products - trigger: - type: http - httpRequest: - url: http://otel-frontend:8084/api/products - method: GET - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http" name="API HTTP GET" http.target="/api/products" - http.method="GET"] - assertions: - - attr:http.status_code = 200 - - attr:tracetest.span.duration < 50ms - - selector: span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] - assertions: - - attr:rpc.grpc.status_code = 0 - - selector: span[tracetest.span.type="rpc" name="hipstershop.ProductCatalogService/ListProducts" - rpc.system="grpc" rpc.method="ListProducts" rpc.service="hipstershop.ProductCatalogService"] - assertions: - - attr:rpc.grpc.status_code = 0 diff --git a/examples/tracetest-new-relic/tracetest/collector.config.yaml b/examples/tracetest-new-relic/tracetest/collector.config.yaml deleted file mode 100644 index dd52a27b9f..0000000000 --- a/examples/tracetest-new-relic/tracetest/collector.config.yaml +++ /dev/null @@ -1,36 +0,0 @@ -receivers: - otlp: - protocols: - grpc: - http: - -processors: - batch: - timeout: 100ms - -exporters: - logging: - logLevel: debug - # OTLP for Tracetest - otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - tls: - insecure: true - # OTLP for New Relic - otlp/newrelic: - endpoint: otlp.nr-data.net:443 - headers: - api-key: # Send traces to New Relic. - # Read more in docs here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-setup/#collector-export - # And here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/collector/opentelemetry-collector-basic/ - -service: - pipelines: - traces/tracetest: - receivers: [otlp] - processors: [batch] - exporters: [otlp/tracetest] - traces/newrelic: - receivers: [otlp] - processors: [batch] - exporters: [logging, otlp/newrelic] diff --git a/examples/tracetest-new-relic/tracetest/docker-compose.yaml b/examples/tracetest-new-relic/tracetest/docker-compose.yaml deleted file mode 100644 index 0e918b5fc9..0000000000 --- a/examples/tracetest-new-relic/tracetest/docker-compose.yaml +++ /dev/null @@ -1,50 +0,0 @@ -version: "3.2" -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-new-relic/tracetest/tracetest-config.yaml b/examples/tracetest-new-relic/tracetest/tracetest-config.yaml deleted file mode 100644 index 7ff7e5de6c..0000000000 --- a/examples/tracetest-new-relic/tracetest/tracetest-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-new-relic/tracetest/tracetest-provision.yaml b/examples/tracetest-new-relic/tracetest/tracetest-provision.yaml deleted file mode 100644 index 0d902699f9..0000000000 --- a/examples/tracetest-new-relic/tracetest/tracetest-provision.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -type: DataStore -spec: - name: New Relic - type: newrelic - default: true - ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://otel-frontend:8084 - productCatalogEndpoint: otel-productcatalogservice:3550 - cartEndpoint: otel-cartservice:7070 - checkoutEndpoint: otel-checkoutservice:5050 From 1dc415a287f4b6e2330ea84024c7339d8f7e3a05 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:17:10 -0600 Subject: [PATCH 03/12] updating new relic example --- examples/tracetest-new-relic/.env.template | 54 +++++++++++++++++++ examples/tracetest-new-relic/.gitignore | 1 + .../tracetest-new-relic/Dockerfile.tracetest | 11 ++++ .../tracetest-new-relic/collector.config.yaml | 34 ++++++++++++ .../tracetest-new-relic/resources/apply.sh | 17 ++++++ .../resources/datastore.yaml | 6 +++ examples/tracetest-new-relic/resources/run.sh | 16 ++++++ .../tracetest-new-relic/resources/test.yaml | 28 ++++++++++ 8 files changed, 167 insertions(+) create mode 100644 examples/tracetest-new-relic/.env.template create mode 100644 examples/tracetest-new-relic/.gitignore create mode 100644 examples/tracetest-new-relic/Dockerfile.tracetest create mode 100644 examples/tracetest-new-relic/collector.config.yaml create mode 100644 examples/tracetest-new-relic/resources/apply.sh create mode 100644 examples/tracetest-new-relic/resources/datastore.yaml create mode 100644 examples/tracetest-new-relic/resources/run.sh create mode 100644 examples/tracetest-new-relic/resources/test.yaml diff --git a/examples/tracetest-new-relic/.env.template b/examples/tracetest-new-relic/.env.template new file mode 100644 index 0000000000..872be54986 --- /dev/null +++ b/examples/tracetest-new-relic/.env.template @@ -0,0 +1,54 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + +NEW_RELIC_INGEST_LICENSE="" + +# Collector +OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 +OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} +OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} + +# Frontend +FRONTEND_PORT=8084 +FRONTEND_ADDR=otel-frontend:${FRONTEND_PORT} + +# Redis +REDIS_PORT=6379 +REDIS_ADDR=cache:${REDIS_PORT} + +# Services +AD_SERVICE_PORT=9555 +AD_SERVICE_ADDR=otel-adservice:${AD_SERVICE_PORT} + +CART_SERVICE_PORT=7070 +CART_SERVICE_ADDR=otel-cartservice:${CART_SERVICE_PORT} + +CHECKOUT_SERVICE_PORT=5050 +CHECKOUT_SERVICE_ADDR=otel-checkoutservice:${CHECKOUT_SERVICE_PORT} + +CURRENCY_SERVICE_PORT=7001 +CURRENCY_SERVICE_ADDR=otel-currencyservice:${CURRENCY_SERVICE_PORT} + +EMAIL_SERVICE_PORT=6060 +EMAIL_SERVICE_ADDR=otel-http://emailservice:${EMAIL_SERVICE_PORT} + +PAYMENT_SERVICE_PORT=50051 +PAYMENT_SERVICE_ADDR=otel-paymentservice:${PAYMENT_SERVICE_PORT} + +PRODUCT_CATALOG_SERVICE_PORT=3550 +PRODUCT_CATALOG_SERVICE_ADDR=otel-productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} + +RECOMMENDATION_SERVICE_PORT=9001 +RECOMMENDATION_SERVICE_ADDR=otel-recommendationservice:${RECOMMENDATION_SERVICE_PORT} + +SHIPPING_SERVICE_PORT=50050 +SHIPPING_SERVICE_ADDR=otel-shippingservice:${SHIPPING_SERVICE_PORT} + +FEATURE_FLAG_SERVICE_PORT=8083 +FEATURE_FLAG_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_SERVICE_PORT} +FEATURE_FLAG_GRPC_SERVICE_PORT=50053 +FEATURE_FLAG_GRPC_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} + +ENV_PLATFORM=local \ No newline at end of file diff --git a/examples/tracetest-new-relic/.gitignore b/examples/tracetest-new-relic/.gitignore new file mode 100644 index 0000000000..4c49bd78f1 --- /dev/null +++ b/examples/tracetest-new-relic/.gitignore @@ -0,0 +1 @@ +.env diff --git a/examples/tracetest-new-relic/Dockerfile.tracetest b/examples/tracetest-new-relic/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-new-relic/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-new-relic/collector.config.yaml b/examples/tracetest-new-relic/collector.config.yaml new file mode 100644 index 0000000000..256e26467f --- /dev/null +++ b/examples/tracetest-new-relic/collector.config.yaml @@ -0,0 +1,34 @@ +receivers: + otlp: + protocols: + grpc: + http: + +processors: + batch: + timeout: 100ms + +exporters: + # OTLP for Tracetest + otlp/tracetest: + endpoint: tracetest-agent:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + tls: + insecure: true + # OTLP for New Relic + otlp/newrelic: + endpoint: otlp.nr-data.net:443 + headers: + api-key: ${NEW_RELIC_INGEST_LICENSE} # Send traces to New Relic. + # Read more in docs here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-setup/#collector-export + # And here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/collector/opentelemetry-collector-basic/ + +service: + pipelines: + traces/tracetest: + receivers: [otlp] + processors: [batch] + exporters: [otlp/tracetest] + traces/newrelic: + receivers: [otlp] + processors: [batch] + exporters: [otlp/newrelic] diff --git a/examples/tracetest-new-relic/resources/apply.sh b/examples/tracetest-new-relic/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-new-relic/resources/apply.sh @@ -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 diff --git a/examples/tracetest-new-relic/resources/datastore.yaml b/examples/tracetest-new-relic/resources/datastore.yaml new file mode 100644 index 0000000000..6e2d51aa59 --- /dev/null +++ b/examples/tracetest-new-relic/resources/datastore.yaml @@ -0,0 +1,6 @@ +--- +type: DataStore +spec: + id: current + name: New Relic + type: newrelic diff --git a/examples/tracetest-new-relic/resources/run.sh b/examples/tracetest-new-relic/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-new-relic/resources/run.sh @@ -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 diff --git a/examples/tracetest-new-relic/resources/test.yaml b/examples/tracetest-new-relic/resources/test.yaml new file mode 100644 index 0000000000..2e733f6ffa --- /dev/null +++ b/examples/tracetest-new-relic/resources/test.yaml @@ -0,0 +1,28 @@ +type: Test +spec: + id: YJmFC7hVg + name: Otel - List Products + description: Otel - List Products + trigger: + type: http + httpRequest: + url: http://otel-frontend:8084/api/products + method: GET + headers: + - key: Content-Type + value: application/json + specs: + - selector: + span[tracetest.span.type="http" name="API HTTP GET" http.target="/api/products" + http.method="GET"] + assertions: + - attr:http.status_code = 200 + - attr:tracetest.span.duration < 50ms + - selector: span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] + assertions: + - attr:rpc.grpc.status_code = 0 + - selector: + span[tracetest.span.type="rpc" name="hipstershop.ProductCatalogService/ListProducts" + rpc.system="grpc" rpc.method="ListProducts" rpc.service="hipstershop.ProductCatalogService"] + assertions: + - attr:rpc.grpc.status_code = 0 From 4002218abc5a24a538a77f26e4041b05ac12d1e0 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:17:35 -0600 Subject: [PATCH 04/12] updating new relic example --- examples/tracetest-new-relic/.env | 53 ------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 examples/tracetest-new-relic/.env diff --git a/examples/tracetest-new-relic/.env b/examples/tracetest-new-relic/.env deleted file mode 100644 index 04ff7d7235..0000000000 --- a/examples/tracetest-new-relic/.env +++ /dev/null @@ -1,53 +0,0 @@ -# Get the required information here: https://app.tracetest.io/retrieve-token - -TRACETEST_TOKEN="MCiA34CIR" -TRACETEST_ENVIRONMENT_ID="ttenv_b42fa137465c6e04" -NEW_RELIC_INGEST_LICENSE="" - -# Collector -OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 -OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} -OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} - -# Frontend -FRONTEND_PORT=8084 -FRONTEND_ADDR=otel-frontend:${FRONTEND_PORT} - -# Redis -REDIS_PORT=6379 -REDIS_ADDR=cache:${REDIS_PORT} - -# Services -AD_SERVICE_PORT=9555 -AD_SERVICE_ADDR=otel-adservice:${AD_SERVICE_PORT} - -CART_SERVICE_PORT=7070 -CART_SERVICE_ADDR=otel-cartservice:${CART_SERVICE_PORT} - -CHECKOUT_SERVICE_PORT=5050 -CHECKOUT_SERVICE_ADDR=otel-checkoutservice:${CHECKOUT_SERVICE_PORT} - -CURRENCY_SERVICE_PORT=7001 -CURRENCY_SERVICE_ADDR=otel-currencyservice:${CURRENCY_SERVICE_PORT} - -EMAIL_SERVICE_PORT=6060 -EMAIL_SERVICE_ADDR=otel-http://emailservice:${EMAIL_SERVICE_PORT} - -PAYMENT_SERVICE_PORT=50051 -PAYMENT_SERVICE_ADDR=otel-paymentservice:${PAYMENT_SERVICE_PORT} - -PRODUCT_CATALOG_SERVICE_PORT=3550 -PRODUCT_CATALOG_SERVICE_ADDR=otel-productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} - -RECOMMENDATION_SERVICE_PORT=9001 -RECOMMENDATION_SERVICE_ADDR=otel-recommendationservice:${RECOMMENDATION_SERVICE_PORT} - -SHIPPING_SERVICE_PORT=50050 -SHIPPING_SERVICE_ADDR=otel-shippingservice:${SHIPPING_SERVICE_PORT} - -FEATURE_FLAG_SERVICE_PORT=8083 -FEATURE_FLAG_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_SERVICE_PORT} -FEATURE_FLAG_GRPC_SERVICE_PORT=50053 -FEATURE_FLAG_GRPC_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} - -ENV_PLATFORM=local \ No newline at end of file From f21a04f505d8058edd07a28e00d3a552d0edddd4 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:32:08 -0600 Subject: [PATCH 05/12] updating datadog example --- examples/tracetest-datadog/.env | 85 ------------------- examples/tracetest-datadog/.env.template | 54 ++++++++++++ examples/tracetest-datadog/.gitignore | 1 + .../tracetest-datadog/Dockerfile.tracetest | 11 +++ .../{tracetest => }/collector.config.yaml | 5 +- .../tracetest-datadog/docker-compose.yaml | 74 ++++++++++++++-- examples/tracetest-datadog/resources/apply.sh | 17 ++++ .../resources/datastore.yaml | 5 ++ examples/tracetest-datadog/resources/run.sh | 16 ++++ .../{http-test.yaml => resources/test.yaml} | 0 .../tracetest/docker-compose.yaml | 59 ------------- .../tracetest/tracetest-config.yaml | 23 ----- .../tracetest/tracetest-provision.yaml | 27 ------ 13 files changed, 174 insertions(+), 203 deletions(-) delete mode 100644 examples/tracetest-datadog/.env create mode 100644 examples/tracetest-datadog/.env.template create mode 100644 examples/tracetest-datadog/.gitignore create mode 100644 examples/tracetest-datadog/Dockerfile.tracetest rename examples/tracetest-datadog/{tracetest => }/collector.config.yaml (86%) create mode 100644 examples/tracetest-datadog/resources/apply.sh create mode 100644 examples/tracetest-datadog/resources/datastore.yaml create mode 100644 examples/tracetest-datadog/resources/run.sh rename examples/tracetest-datadog/{http-test.yaml => resources/test.yaml} (100%) delete mode 100644 examples/tracetest-datadog/tracetest/docker-compose.yaml delete mode 100644 examples/tracetest-datadog/tracetest/tracetest-config.yaml delete mode 100644 examples/tracetest-datadog/tracetest/tracetest-provision.yaml diff --git a/examples/tracetest-datadog/.env b/examples/tracetest-datadog/.env deleted file mode 100644 index 3fd31c808e..0000000000 --- a/examples/tracetest-datadog/.env +++ /dev/null @@ -1,85 +0,0 @@ -# Images -IMAGE_VERSION=1.3.0 -IMAGE_NAME=ghcr.io/open-telemetry/demo - -# Demo Platform -ENV_PLATFORM=local - -# OpenTelemetry Collector -OTEL_COLLECTOR_HOST=otel-collector -OTEL_COLLECTOR_PORT=4317 -OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT} -OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} -OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} -PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces - -# OpenTelemetry Resource Definitions -OTEL_RESOURCE_ATTRIBUTES="service.namespace=opentelemetry-demo" - -# Metrics Temporality -OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative - -# ****************** -# Core Demo Services -# ****************** -# Ad Service -AD_SERVICE_PORT=9555 -AD_SERVICE_ADDR=adservice:${AD_SERVICE_PORT} - -# Cart Service -CART_SERVICE_PORT=7070 -CART_SERVICE_ADDR=cartservice:${CART_SERVICE_PORT} - -# Checkout Service -CHECKOUT_SERVICE_PORT=5050 -CHECKOUT_SERVICE_ADDR=checkoutservice:${CHECKOUT_SERVICE_PORT} - -# Currency Service -CURRENCY_SERVICE_PORT=7001 -CURRENCY_SERVICE_ADDR=currencyservice:${CURRENCY_SERVICE_PORT} - -# Email Service -EMAIL_SERVICE_PORT=6060 -EMAIL_SERVICE_ADDR=http://emailservice:${EMAIL_SERVICE_PORT} - -# Feature Flag Service -FEATURE_FLAG_SERVICE_PORT=8081 -FEATURE_FLAG_SERVICE_ADDR=featureflagservice:${FEATURE_FLAG_SERVICE_PORT} -FEATURE_FLAG_SERVICE_HOST=feature-flag-service -FEATURE_FLAG_GRPC_SERVICE_PORT=50053 -FEATURE_FLAG_GRPC_SERVICE_ADDR=featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} - -# Frontend -FRONTEND_PORT=8084 -FRONTEND_ADDR=frontend:${FRONTEND_PORT} - -# Payment Service -PAYMENT_SERVICE_PORT=50051 -PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT} - -# Product Catalog Service -PRODUCT_CATALOG_SERVICE_PORT=3550 -PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} - -# Quote Service -QUOTE_SERVICE_PORT=8090 -QUOTE_SERVICE_ADDR=http://quoteservice:${QUOTE_SERVICE_PORT} - -# Recommendation Service -RECOMMENDATION_SERVICE_PORT=9001 -RECOMMENDATION_SERVICE_ADDR=recommendationservice:${RECOMMENDATION_SERVICE_PORT} - -# Shipping Service -SHIPPING_SERVICE_PORT=50050 -SHIPPING_SERVICE_ADDR=shippingservice:${SHIPPING_SERVICE_PORT} - -# ****************** -# Dependent Services -# ****************** -# Kafka -KAFKA_SERVICE_PORT=9092 -KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT} - -# Redis -REDIS_PORT=6379 -REDIS_ADDR=redis-cart:${REDIS_PORT} diff --git a/examples/tracetest-datadog/.env.template b/examples/tracetest-datadog/.env.template new file mode 100644 index 0000000000..afd0ca8fc7 --- /dev/null +++ b/examples/tracetest-datadog/.env.template @@ -0,0 +1,54 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + +DATADOG_API_KEY="" + +# Collector +OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 +OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} +OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} + +# Frontend +FRONTEND_PORT=8084 +FRONTEND_ADDR=otel-frontend:${FRONTEND_PORT} + +# Redis +REDIS_PORT=6379 +REDIS_ADDR=cache:${REDIS_PORT} + +# Services +AD_SERVICE_PORT=9555 +AD_SERVICE_ADDR=otel-adservice:${AD_SERVICE_PORT} + +CART_SERVICE_PORT=7070 +CART_SERVICE_ADDR=otel-cartservice:${CART_SERVICE_PORT} + +CHECKOUT_SERVICE_PORT=5050 +CHECKOUT_SERVICE_ADDR=otel-checkoutservice:${CHECKOUT_SERVICE_PORT} + +CURRENCY_SERVICE_PORT=7001 +CURRENCY_SERVICE_ADDR=otel-currencyservice:${CURRENCY_SERVICE_PORT} + +EMAIL_SERVICE_PORT=6060 +EMAIL_SERVICE_ADDR=otel-http://emailservice:${EMAIL_SERVICE_PORT} + +PAYMENT_SERVICE_PORT=50051 +PAYMENT_SERVICE_ADDR=otel-paymentservice:${PAYMENT_SERVICE_PORT} + +PRODUCT_CATALOG_SERVICE_PORT=3550 +PRODUCT_CATALOG_SERVICE_ADDR=otel-productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} + +RECOMMENDATION_SERVICE_PORT=9001 +RECOMMENDATION_SERVICE_ADDR=otel-recommendationservice:${RECOMMENDATION_SERVICE_PORT} + +SHIPPING_SERVICE_PORT=50050 +SHIPPING_SERVICE_ADDR=otel-shippingservice:${SHIPPING_SERVICE_PORT} + +FEATURE_FLAG_SERVICE_PORT=8083 +FEATURE_FLAG_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_SERVICE_PORT} +FEATURE_FLAG_GRPC_SERVICE_PORT=50053 +FEATURE_FLAG_GRPC_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} + +ENV_PLATFORM=local \ No newline at end of file diff --git a/examples/tracetest-datadog/.gitignore b/examples/tracetest-datadog/.gitignore new file mode 100644 index 0000000000..4c49bd78f1 --- /dev/null +++ b/examples/tracetest-datadog/.gitignore @@ -0,0 +1 @@ +.env diff --git a/examples/tracetest-datadog/Dockerfile.tracetest b/examples/tracetest-datadog/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-datadog/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-datadog/tracetest/collector.config.yaml b/examples/tracetest-datadog/collector.config.yaml similarity index 86% rename from examples/tracetest-datadog/tracetest/collector.config.yaml rename to examples/tracetest-datadog/collector.config.yaml index 89b2f78750..20130b49ac 100644 --- a/examples/tracetest-datadog/tracetest/collector.config.yaml +++ b/examples/tracetest-datadog/collector.config.yaml @@ -42,8 +42,7 @@ processors: exporters: # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # Datadog exporter @@ -52,7 +51,7 @@ exporters: datadog: api: site: datadoghq.com - key: ${DATADOG_API_KEY} # Add here you API key for Datadog + key: ${env:DATADOG_API_KEY} # Add here you API key for Datadog service: pipelines: diff --git a/examples/tracetest-datadog/docker-compose.yaml b/examples/tracetest-datadog/docker-compose.yaml index 1b3b4e9b62..5dd55b69c5 100644 --- a/examples/tracetest-datadog/docker-compose.yaml +++ b/examples/tracetest-datadog/docker-compose.yaml @@ -16,7 +16,7 @@ # to disable the metrics and rely on OTel collector container # defined on ./tracetest/docker-compose.yaml -version: '3.9' +version: "3.9" x-default-logging: &logging driver: "json-file" options: @@ -29,6 +29,50 @@ networks: driver: bridge services: + # 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} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null + depends_on: + frontend: + condition: service_healthy + 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 + # ****************** # Core Demo Services # ****************** @@ -164,7 +208,7 @@ services: environment: - CURRENCY_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - - OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME + - OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME depends_on: - otel-collector logging: *logging @@ -202,8 +246,8 @@ services: memory: 200M restart: unless-stopped ports: - - "${FEATURE_FLAG_SERVICE_PORT}" # Feature Flag Service UI - - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" # Feature Flag Service gRPC API + - "${FEATURE_FLAG_SERVICE_PORT}" # Feature Flag Service UI + - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" # Feature Flag Service gRPC API environment: - FEATURE_FLAG_SERVICE_PORT - FEATURE_FLAG_GRPC_SERVICE_PORT @@ -213,7 +257,8 @@ services: - DATABASE_URL=ecto://ffs:ffs@ffs_postgres:5432/ffs - FEATURE_FLAG_SERVICE_PATH_ROOT="/feature" healthcheck: - test: ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"] + test: + ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"] depends_on: ffs_postgres: condition: service_healthy @@ -281,6 +326,11 @@ services: - recommendationservice - shippingservice logging: *logging + healthcheck: + test: ["CMD", "wget", "--spider", "localhost:8084"] + interval: 1s + timeout: 3s + retries: 60 # Payment service paymentservice: @@ -359,7 +409,7 @@ services: deploy: resources: limits: - memory: 500M # This is high to enable supporting the recommendationCache feature flag use case + memory: 500M # This is high to enable supporting the recommendationCache feature flag use case restart: unless-stopped ports: - "${RECOMMENDATION_SERVICE_PORT}" @@ -465,3 +515,15 @@ services: ports: - "${REDIS_PORT}" logging: *logging + + otel-collector: + image: otel/opentelemetry-collector-contrib:0.100.0 + container_name: otel-collector + restart: unless-stopped + environment: + - DATADOG_API_KEY + command: + - "--config" + - "/otel-local-config.yaml" + volumes: + - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-datadog/resources/apply.sh b/examples/tracetest-datadog/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-datadog/resources/apply.sh @@ -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 diff --git a/examples/tracetest-datadog/resources/datastore.yaml b/examples/tracetest-datadog/resources/datastore.yaml new file mode 100644 index 0000000000..cd9cf0dc4a --- /dev/null +++ b/examples/tracetest-datadog/resources/datastore.yaml @@ -0,0 +1,5 @@ +type: DataStore +spec: + id: current + name: datadog + type: datadog diff --git a/examples/tracetest-datadog/resources/run.sh b/examples/tracetest-datadog/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-datadog/resources/run.sh @@ -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 diff --git a/examples/tracetest-datadog/http-test.yaml b/examples/tracetest-datadog/resources/test.yaml similarity index 100% rename from examples/tracetest-datadog/http-test.yaml rename to examples/tracetest-datadog/resources/test.yaml diff --git a/examples/tracetest-datadog/tracetest/docker-compose.yaml b/examples/tracetest-datadog/tracetest/docker-compose.yaml deleted file mode 100644 index f4a5153156..0000000000 --- a/examples/tracetest-datadog/tracetest/docker-compose.yaml +++ /dev/null @@ -1,59 +0,0 @@ -version: "3.9" - -networks: - default: - name: opentelemetry-demo - driver: bridge - -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - container_name: tracetest - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provisioning.yaml - command: --provisioning-file /app/provisioning.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - tt-postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - tt-postgres: - image: postgres:14 - container_name: tt-postgres - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - container_name: otel-collector - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-datadog/tracetest/tracetest-config.yaml b/examples/tracetest-datadog/tracetest/tracetest-config.yaml deleted file mode 100644 index 3edb085fe2..0000000000 --- a/examples/tracetest-datadog/tracetest/tracetest-config.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -postgres: - host: tt-postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-datadog/tracetest/tracetest-provision.yaml b/examples/tracetest-datadog/tracetest/tracetest-provision.yaml deleted file mode 100644 index 4144adcdbe..0000000000 --- a/examples/tracetest-datadog/tracetest/tracetest-provision.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://frontend:8084 - productCatalogEndpoint: productcatalogservice:3550 - cartEndpoint: cartservice:7070 - checkoutEndpoint: checkoutservice:5050 - ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 180s - ---- -type: DataStore -spec: - name: datadog - type: datadog From 7bbe6a1af22e5fb35be0cfb0fe7dae0ff0fb6344 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:39:48 -0600 Subject: [PATCH 06/12] updating dynatrace example --- examples/tracetest-datadog/.env.template | 84 ++++++++++++++----- .../{.env => .env.template} | 6 ++ .../tracetest-dynatrace/Dockerfile.tracetest | 11 +++ .../{tracetest => }/collector.config.yaml | 5 +- .../tracetest-dynatrace/docker-compose.yaml | 78 +++++++++++++++-- .../tracetest-dynatrace/resources/apply.sh | 17 ++++ .../resources/datastore.yaml | 5 ++ examples/tracetest-dynatrace/resources/run.sh | 16 ++++ .../{http-test.yaml => resources/test.yaml} | 0 .../tracetest/docker-compose.yaml | 59 ------------- .../tracetest/tracetest-config.yaml | 23 ----- .../tracetest/tracetest-provision.yaml | 36 -------- 12 files changed, 188 insertions(+), 152 deletions(-) rename examples/tracetest-dynatrace/{.env => .env.template} (92%) create mode 100644 examples/tracetest-dynatrace/Dockerfile.tracetest rename examples/tracetest-dynatrace/{tracetest => }/collector.config.yaml (82%) create mode 100644 examples/tracetest-dynatrace/resources/apply.sh create mode 100644 examples/tracetest-dynatrace/resources/datastore.yaml create mode 100644 examples/tracetest-dynatrace/resources/run.sh rename examples/tracetest-dynatrace/{http-test.yaml => resources/test.yaml} (100%) delete mode 100644 examples/tracetest-dynatrace/tracetest/docker-compose.yaml delete mode 100644 examples/tracetest-dynatrace/tracetest/tracetest-config.yaml delete mode 100644 examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml diff --git a/examples/tracetest-datadog/.env.template b/examples/tracetest-datadog/.env.template index afd0ca8fc7..3e1a3fa1f8 100644 --- a/examples/tracetest-datadog/.env.template +++ b/examples/tracetest-datadog/.env.template @@ -5,50 +5,88 @@ TRACETEST_ENVIRONMENT_ID="" DATADOG_API_KEY="" -# Collector -OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 +# Images +IMAGE_VERSION=1.3.0 +IMAGE_NAME=ghcr.io/open-telemetry/demo + +# Demo Platform +ENV_PLATFORM=local + +# OpenTelemetry Collector +OTEL_COLLECTOR_HOST=otel-collector +OTEL_COLLECTOR_PORT=4317 +OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT} OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} +PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces -# Frontend -FRONTEND_PORT=8084 -FRONTEND_ADDR=otel-frontend:${FRONTEND_PORT} +# OpenTelemetry Resource Definitions +OTEL_RESOURCE_ATTRIBUTES="service.namespace=opentelemetry-demo" -# Redis -REDIS_PORT=6379 -REDIS_ADDR=cache:${REDIS_PORT} +# Metrics Temporality +OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative -# Services +# ****************** +# Core Demo Services +# ****************** +# Ad Service AD_SERVICE_PORT=9555 -AD_SERVICE_ADDR=otel-adservice:${AD_SERVICE_PORT} +AD_SERVICE_ADDR=adservice:${AD_SERVICE_PORT} +# Cart Service CART_SERVICE_PORT=7070 -CART_SERVICE_ADDR=otel-cartservice:${CART_SERVICE_PORT} +CART_SERVICE_ADDR=cartservice:${CART_SERVICE_PORT} +# Checkout Service CHECKOUT_SERVICE_PORT=5050 -CHECKOUT_SERVICE_ADDR=otel-checkoutservice:${CHECKOUT_SERVICE_PORT} +CHECKOUT_SERVICE_ADDR=checkoutservice:${CHECKOUT_SERVICE_PORT} +# Currency Service CURRENCY_SERVICE_PORT=7001 -CURRENCY_SERVICE_ADDR=otel-currencyservice:${CURRENCY_SERVICE_PORT} +CURRENCY_SERVICE_ADDR=currencyservice:${CURRENCY_SERVICE_PORT} +# Email Service EMAIL_SERVICE_PORT=6060 -EMAIL_SERVICE_ADDR=otel-http://emailservice:${EMAIL_SERVICE_PORT} +EMAIL_SERVICE_ADDR=http://emailservice:${EMAIL_SERVICE_PORT} + +# Feature Flag Service +FEATURE_FLAG_SERVICE_PORT=8081 +FEATURE_FLAG_SERVICE_ADDR=featureflagservice:${FEATURE_FLAG_SERVICE_PORT} +FEATURE_FLAG_SERVICE_HOST=feature-flag-service +FEATURE_FLAG_GRPC_SERVICE_PORT=50053 +FEATURE_FLAG_GRPC_SERVICE_ADDR=featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} +# Frontend +FRONTEND_PORT=8084 +FRONTEND_ADDR=frontend:${FRONTEND_PORT} + +# Payment Service PAYMENT_SERVICE_PORT=50051 -PAYMENT_SERVICE_ADDR=otel-paymentservice:${PAYMENT_SERVICE_PORT} +PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT} +# Product Catalog Service PRODUCT_CATALOG_SERVICE_PORT=3550 -PRODUCT_CATALOG_SERVICE_ADDR=otel-productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} +PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT} + +# Quote Service +QUOTE_SERVICE_PORT=8090 +QUOTE_SERVICE_ADDR=http://quoteservice:${QUOTE_SERVICE_PORT} +# Recommendation Service RECOMMENDATION_SERVICE_PORT=9001 -RECOMMENDATION_SERVICE_ADDR=otel-recommendationservice:${RECOMMENDATION_SERVICE_PORT} +RECOMMENDATION_SERVICE_ADDR=recommendationservice:${RECOMMENDATION_SERVICE_PORT} +# Shipping Service SHIPPING_SERVICE_PORT=50050 -SHIPPING_SERVICE_ADDR=otel-shippingservice:${SHIPPING_SERVICE_PORT} +SHIPPING_SERVICE_ADDR=shippingservice:${SHIPPING_SERVICE_PORT} -FEATURE_FLAG_SERVICE_PORT=8083 -FEATURE_FLAG_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_SERVICE_PORT} -FEATURE_FLAG_GRPC_SERVICE_PORT=50053 -FEATURE_FLAG_GRPC_SERVICE_ADDR=otel-featureflagservice:${FEATURE_FLAG_GRPC_SERVICE_PORT} +# ****************** +# Dependent Services +# ****************** +# Kafka +KAFKA_SERVICE_PORT=9092 +KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT} -ENV_PLATFORM=local \ No newline at end of file +# Redis +REDIS_PORT=6379 +REDIS_ADDR=redis-cart:${REDIS_PORT} diff --git a/examples/tracetest-dynatrace/.env b/examples/tracetest-dynatrace/.env.template similarity index 92% rename from examples/tracetest-dynatrace/.env rename to examples/tracetest-dynatrace/.env.template index 3fd31c808e..53e73a3657 100644 --- a/examples/tracetest-dynatrace/.env +++ b/examples/tracetest-dynatrace/.env.template @@ -1,3 +1,9 @@ +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="MCiA34CIR" +TRACETEST_ENVIRONMENT_ID="ttenv_b42fa137465c6e04" +DYNATRACE_SECRET="" + # Images IMAGE_VERSION=1.3.0 IMAGE_NAME=ghcr.io/open-telemetry/demo diff --git a/examples/tracetest-dynatrace/Dockerfile.tracetest b/examples/tracetest-dynatrace/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-dynatrace/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-dynatrace/tracetest/collector.config.yaml b/examples/tracetest-dynatrace/collector.config.yaml similarity index 82% rename from examples/tracetest-dynatrace/tracetest/collector.config.yaml rename to examples/tracetest-dynatrace/collector.config.yaml index d41e40b9cd..e4ee4490b0 100644 --- a/examples/tracetest-dynatrace/tracetest/collector.config.yaml +++ b/examples/tracetest-dynatrace/collector.config.yaml @@ -41,15 +41,14 @@ processors: exporters: # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # OTLP for Dynatrace otlphttp/dynatrace: endpoint: https://abc12345.live.dynatrace.com/api/v2/otlp headers: - Authorization: "Api-Token dt0c01.sample.secret" # Requires "openTelemetryTrace.ingest" permission + Authorization: "Api-Token ${DYNATRACE_SECRET}" # Requires "openTelemetryTrace.ingest" permission service: pipelines: diff --git a/examples/tracetest-dynatrace/docker-compose.yaml b/examples/tracetest-dynatrace/docker-compose.yaml index f0961154e2..6a40d96780 100644 --- a/examples/tracetest-dynatrace/docker-compose.yaml +++ b/examples/tracetest-dynatrace/docker-compose.yaml @@ -16,7 +16,7 @@ # to disable the metrics and rely on OTel collector container # defined on ./tracetest/docker-compose.yaml -version: '3.9' +version: "3.9" x-default-logging: &logging driver: "json-file" options: @@ -29,6 +29,50 @@ networks: driver: bridge services: + # 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} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null + depends_on: + frontend: + condition: service_healthy + 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 + # ****************** # Core Demo Services # ****************** @@ -164,7 +208,7 @@ services: environment: - CURRENCY_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - - OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME + - OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME depends_on: - otel-collector logging: *logging @@ -202,8 +246,8 @@ services: memory: 200M restart: unless-stopped ports: - - "${FEATURE_FLAG_SERVICE_PORT}" # Feature Flag Service UI - - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" # Feature Flag Service gRPC API + - "${FEATURE_FLAG_SERVICE_PORT}" # Feature Flag Service UI + - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" # Feature Flag Service gRPC API environment: - FEATURE_FLAG_SERVICE_PORT - FEATURE_FLAG_GRPC_SERVICE_PORT @@ -213,7 +257,8 @@ services: - DATABASE_URL=ecto://ffs:ffs@ffs_postgres:5432/ffs - FEATURE_FLAG_SERVICE_PATH_ROOT="/feature" healthcheck: - test: ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"] + test: + ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"] depends_on: ffs_postgres: condition: service_healthy @@ -281,6 +326,11 @@ services: - recommendationservice - shippingservice logging: *logging + healthcheck: + test: ["CMD", "wget", "--spider", "localhost:8084"] + interval: 1s + timeout: 3s + retries: 60 # Payment service paymentservice: @@ -290,7 +340,7 @@ services: deploy: resources: limits: - memory: 200M + memory: 70M restart: unless-stopped ports: - "${PAYMENT_SERVICE_PORT}" @@ -359,7 +409,7 @@ services: deploy: resources: limits: - memory: 500M # This is high to enable supporting the recommendationCache feature flag use case + memory: 500M # This is high to enable supporting the recommendationCache feature flag use case restart: unless-stopped ports: - "${RECOMMENDATION_SERVICE_PORT}" @@ -450,7 +500,7 @@ services: start_period: 10s interval: 5s timeout: 10s - retries: 10000 + retries: 10 # Redis used by Cart service redis-cart: @@ -465,3 +515,15 @@ services: ports: - "${REDIS_PORT}" logging: *logging + + otel-collector: + image: otel/opentelemetry-collector-contrib:0.100.0 + container_name: otel-collector + restart: unless-stopped + environment: + - DYNATRACE_SECRET + command: + - "--config" + - "/otel-local-config.yaml" + volumes: + - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-dynatrace/resources/apply.sh b/examples/tracetest-dynatrace/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-dynatrace/resources/apply.sh @@ -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 diff --git a/examples/tracetest-dynatrace/resources/datastore.yaml b/examples/tracetest-dynatrace/resources/datastore.yaml new file mode 100644 index 0000000000..a05f4656d2 --- /dev/null +++ b/examples/tracetest-dynatrace/resources/datastore.yaml @@ -0,0 +1,5 @@ +type: DataStore +spec: + id: current + name: Dynatrace + type: dynatrace diff --git a/examples/tracetest-dynatrace/resources/run.sh b/examples/tracetest-dynatrace/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-dynatrace/resources/run.sh @@ -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 diff --git a/examples/tracetest-dynatrace/http-test.yaml b/examples/tracetest-dynatrace/resources/test.yaml similarity index 100% rename from examples/tracetest-dynatrace/http-test.yaml rename to examples/tracetest-dynatrace/resources/test.yaml diff --git a/examples/tracetest-dynatrace/tracetest/docker-compose.yaml b/examples/tracetest-dynatrace/tracetest/docker-compose.yaml deleted file mode 100644 index 45bfc78e09..0000000000 --- a/examples/tracetest-dynatrace/tracetest/docker-compose.yaml +++ /dev/null @@ -1,59 +0,0 @@ -version: "3.9" - -networks: - default: - name: opentelemetry-demo - driver: bridge - -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - container_name: tracetest - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provisioning.yaml - command: --provisioning-file /app/provisioning.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - tt-postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - tt-postgres: - image: postgres:14 - container_name: tt-postgres - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.82.0 - container_name: otel-collector - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml b/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml deleted file mode 100644 index 3edb085fe2..0000000000 --- a/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -postgres: - host: tt-postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml b/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml deleted file mode 100644 index a8c140c85a..0000000000 --- a/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://frontend:8084 - productCatalogEndpoint: productcatalogservice:3550 - cartEndpoint: cartservice:7070 - checkoutEndpoint: checkoutservice:5050 - ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 10m - ---- -type: DataStore -spec: - name: Dynatrace - type: dynatrace - ---- -type: TestRunner -spec: - id: current - name: default - requiredGates: - - analyzer-score - - test-specs From 5b4961d3244031efab9ef33c42c71f449247aa21 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 10:50:42 -0600 Subject: [PATCH 07/12] updating honeycomb example --- examples/tracetest-honeycomb/.env.template | 7 +- .../tracetest-honeycomb/Dockerfile.tracetest | 11 +++ .../tracetest-honeycomb/collector.config.yaml | 11 +-- .../docker-compose.agent.yaml | 26 ------- .../tracetest-honeycomb/docker-compose.yaml | 77 +++++++++++-------- .../tracetest-honeycomb/resources/apply.sh | 17 ++++ .../datastore.yaml} | 1 - examples/tracetest-honeycomb/resources/run.sh | 16 ++++ .../{test-api.yaml => resources/test.yaml} | 0 .../tracetest-honeycomb/tracetest-config.yaml | 25 ------ .../tracetest-provision.yaml | 25 ------ 11 files changed, 95 insertions(+), 121 deletions(-) create mode 100644 examples/tracetest-honeycomb/Dockerfile.tracetest delete mode 100644 examples/tracetest-honeycomb/docker-compose.agent.yaml create mode 100644 examples/tracetest-honeycomb/resources/apply.sh rename examples/tracetest-honeycomb/{tracetest-tracing-backend.yaml => resources/datastore.yaml} (95%) create mode 100644 examples/tracetest-honeycomb/resources/run.sh rename examples/tracetest-honeycomb/{test-api.yaml => resources/test.yaml} (100%) delete mode 100644 examples/tracetest-honeycomb/tracetest-config.yaml delete mode 100644 examples/tracetest-honeycomb/tracetest-provision.yaml diff --git a/examples/tracetest-honeycomb/.env.template b/examples/tracetest-honeycomb/.env.template index aeeabffc65..2d069de446 100644 --- a/examples/tracetest-honeycomb/.env.template +++ b/examples/tracetest-honeycomb/.env.template @@ -1,3 +1,6 @@ -TRACETEST_API_KEY="" -TRACETEST_API_TOKEN="" +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + HONEYCOMB_API_KEY="" diff --git a/examples/tracetest-honeycomb/Dockerfile.tracetest b/examples/tracetest-honeycomb/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-honeycomb/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-honeycomb/collector.config.yaml b/examples/tracetest-honeycomb/collector.config.yaml index ba0ef5970a..72055a43c3 100644 --- a/examples/tracetest-honeycomb/collector.config.yaml +++ b/examples/tracetest-honeycomb/collector.config.yaml @@ -12,13 +12,6 @@ exporters: logging: loglevel: debug - # OTLP for Hobby Tracetest Core - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - otlp/tracetest: - endpoint: tracetest:4317 - tls: - insecure: true - # Cloud-based Managed Tracetest otlp/tracetest-agent: endpoint: tracetest-agent:4317 @@ -29,7 +22,7 @@ exporters: otlp/honeycomb: endpoint: "api.honeycomb.io:443" headers: - "x-honeycomb-team": ${HONEYCOMB_API_KEY} + "x-honeycomb-team": ${env:HONEYCOMB_API_KEY} # "x-honeycomb-dataset": "" # optional # Read more in docs here: https://docs.honeycomb.io/getting-data-in/otel-collector/ @@ -38,7 +31,7 @@ service: traces/tracetest: receivers: [otlp] processors: [batch] - exporters: [otlp/tracetest, otlp/tracetest-agent] + exporters: [otlp/tracetest-agent] traces/honeycomb: receivers: [otlp] processors: [batch] diff --git a/examples/tracetest-honeycomb/docker-compose.agent.yaml b/examples/tracetest-honeycomb/docker-compose.agent.yaml deleted file mode 100644 index 53a7d47a52..0000000000 --- a/examples/tracetest-honeycomb/docker-compose.agent.yaml +++ /dev/null @@ -1,26 +0,0 @@ -version: "3" -services: - app: - image: quick-start-nodejs - extra_hosts: - - "host.docker.internal:host-gateway" - build: . - ports: - - "8080:8080" - - # Cloud-based Managed Tracetest - tracetest-agent: - image: kubeshop/tracetest-agent:latest - command: - - "--mode=verbose" - environment: - # Find the Agent API Key here: https://docs.tracetest.io/configuration/agent - - TRACETEST_API_KEY=${TRACETEST_API_KEY} - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.101.0 - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-honeycomb/docker-compose.yaml b/examples/tracetest-honeycomb/docker-compose.yaml index f0a998a174..ba54cdc7cc 100644 --- a/examples/tracetest-honeycomb/docker-compose.yaml +++ b/examples/tracetest-honeycomb/docker-compose.yaml @@ -7,49 +7,60 @@ services: build: . ports: - "8080:8080" - tracetest: - image: kubeshop/tracetest:latest - platform: linux/amd64 - volumes: - - type: bind - source: ./tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest-provision.yaml - target: /app/provisioning.yaml - ports: - - 11633:11633 - command: --provisioning-file /app/provisioning.yaml depends_on: - postgres: - condition: service_healthy otel-collector: condition: service_started - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 + + # Cloud-based Managed Tracetest + tracetest-agent: + image: kubeshop/tracetest-agent:latest environment: - TRACETEST_DEV: ${TRACETEST_DEV} + # Get the required information here: https://app.tracetest.io/retrieve-token + - TRACETEST_API_KEY=${TRACETEST_TOKEN} + - TRACETEST_ENVIRONMENT_ID=${TRACETEST_ENVIRONMENT_ID} - postgres: - image: postgres:14 + tracetest-apply: + build: + dockerfile: Dockerfile.tracetest + volumes: + - ./resources:/resources environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - ports: - - 5432:5432 + TRACETEST_TOKEN: ${TRACETEST_TOKEN} + TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} + 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 otel-collector: - image: otel/opentelemetry-collector-contrib:0.82.0 + image: otel/opentelemetry-collector-contrib:0.101.0 command: - "--config" - "/otel-local-config.yaml" + environment: + - HONEYCOMB_API_KEY volumes: - ./collector.config.yaml:/otel-local-config.yaml diff --git a/examples/tracetest-honeycomb/resources/apply.sh b/examples/tracetest-honeycomb/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-honeycomb/resources/apply.sh @@ -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 diff --git a/examples/tracetest-honeycomb/tracetest-tracing-backend.yaml b/examples/tracetest-honeycomb/resources/datastore.yaml similarity index 95% rename from examples/tracetest-honeycomb/tracetest-tracing-backend.yaml rename to examples/tracetest-honeycomb/resources/datastore.yaml index 92ef90df7c..45da5dfcbc 100644 --- a/examples/tracetest-honeycomb/tracetest-tracing-backend.yaml +++ b/examples/tracetest-honeycomb/resources/datastore.yaml @@ -1,4 +1,3 @@ ---- type: DataStore spec: id: current diff --git a/examples/tracetest-honeycomb/resources/run.sh b/examples/tracetest-honeycomb/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-honeycomb/resources/run.sh @@ -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 diff --git a/examples/tracetest-honeycomb/test-api.yaml b/examples/tracetest-honeycomb/resources/test.yaml similarity index 100% rename from examples/tracetest-honeycomb/test-api.yaml rename to examples/tracetest-honeycomb/resources/test.yaml diff --git a/examples/tracetest-honeycomb/tracetest-config.yaml b/examples/tracetest-honeycomb/tracetest-config.yaml deleted file mode 100644 index 5f2c307848..0000000000 --- a/examples/tracetest-honeycomb/tracetest-config.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -# This section enables sending traces that the Tracetest -# server generates into Honeycomb for a histogram overview. -# View docs here: https://docs.tracetest.io/configuration/telemetry -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-honeycomb/tracetest-provision.yaml b/examples/tracetest-honeycomb/tracetest-provision.yaml deleted file mode 100644 index 81dc652d04..0000000000 --- a/examples/tracetest-honeycomb/tracetest-provision.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 10m - ---- -type: DataStore -spec: - name: Honeycomb - type: honeycomb - default: true - ---- -type: TestRunner -spec: - id: current - name: default - requiredGates: - - analyzer-score - - test-specs From 52dbb74ebb24569f7aed2f917d1dc16a98f26541 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 11:04:40 -0600 Subject: [PATCH 08/12] updating signoz example --- .../tracetest-signoz-pokeshop/.env.template | 6 +- .../docker-compose.agent.yaml | 249 ------------------ .../docker-compose.yaml | 72 +++-- .../tests/curl_get.sh | 1 - .../tests/curl_post.sh | 1 - .../tracetest-signoz-pokeshop/tests/test.yaml | 32 --- .../tracetest/collector.config.yaml | 40 --- .../tracetest/tracetest-config.yaml | 22 -- .../tracetest/tracetest-provision.yaml | 35 --- .../tracetest/tracetest-tracing-backend.yaml | 6 - 10 files changed, 49 insertions(+), 415 deletions(-) delete mode 100644 examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml delete mode 100755 examples/tracetest-signoz-pokeshop/tests/curl_get.sh delete mode 100755 examples/tracetest-signoz-pokeshop/tests/curl_post.sh delete mode 100644 examples/tracetest-signoz-pokeshop/tests/test.yaml delete mode 100644 examples/tracetest-signoz-pokeshop/tracetest/collector.config.yaml delete mode 100644 examples/tracetest-signoz-pokeshop/tracetest/tracetest-config.yaml delete mode 100644 examples/tracetest-signoz-pokeshop/tracetest/tracetest-provision.yaml delete mode 100644 examples/tracetest-signoz-pokeshop/tracetest/tracetest-tracing-backend.yaml diff --git a/examples/tracetest-signoz-pokeshop/.env.template b/examples/tracetest-signoz-pokeshop/.env.template index d780ddb12c..c0437a9d95 100644 --- a/examples/tracetest-signoz-pokeshop/.env.template +++ b/examples/tracetest-signoz-pokeshop/.env.template @@ -1,2 +1,4 @@ -TRACETEST_API_KEY="" -TRACETEST_API_TOKEN="" +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" diff --git a/examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml b/examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml deleted file mode 100644 index fd0617d68a..0000000000 --- a/examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml +++ /dev/null @@ -1,249 +0,0 @@ -version: "3" -services: - - # Cloud-based Managed Tracetest - tracetest-agent: - image: kubeshop/tracetest-agent:latest - command: - - "--mode=verbose" - environment: - # Find the Agent API Key here: https://docs.tracetest.io/configuration/agent - - TRACETEST_API_KEY=${TRACETEST_API_KEY} - - otel-collector: - image: otel/opentelemetry-collector:0.101.0 - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml - ports: - - 4317:4317 - depends_on: - signoz-otel-collector: - condition: service_started - signoz-otel-collector-metrics: - condition: service_started - # Tracetest End - - # SigNoz - zookeeper-1: - image: bitnami/zookeeper:3.7.1 - container_name: zookeeper-1 - hostname: zookeeper-1 - user: root - volumes: - - ./signoz/data/zookeeper-1:/bitnami/zookeeper - environment: - - ZOO_SERVER_ID=1 - - ALLOW_ANONYMOUS_LOGIN=yes - - ZOO_AUTOPURGE_INTERVAL=1 - - clickhouse: - restart: on-failure - image: clickhouse/clickhouse-server:22.8.8-alpine - tty: true - depends_on: - - zookeeper-1 - logging: - options: - max-size: 50m - max-file: "3" - healthcheck: - test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"] - interval: 30s - timeout: 5s - retries: 3 - ulimits: - nproc: 65535 - nofile: - soft: 262144 - hard: 262144 - container_name: clickhouse - hostname: clickhouse - volumes: - - ./signoz/clickhouse-config.xml:/etc/clickhouse-server/config.xml - - ./signoz/clickhouse-users.xml:/etc/clickhouse-server/users.xml - - ./signoz/custom-function.xml:/etc/clickhouse-server/custom-function.xml - - ./signoz/clickhouse-cluster.xml:/etc/clickhouse-server/config.d/cluster.xml - - ./signoz/data/clickhouse/:/var/lib/clickhouse/ - - ./signoz/user_scripts:/var/lib/clickhouse/user_scripts/ - - alertmanager: - image: signoz/alertmanager:${ALERTMANAGER_TAG:-0.23.1} - volumes: - - ./signoz/data/alertmanager:/data - depends_on: - query-service: - condition: service_healthy - restart: on-failure - command: - - --queryService.url=http://query-service:8085 - - --storage.path=/data - - query-service: - image: signoz/query-service:${DOCKER_TAG:-0.22.0} - command: ["-config=/root/config/prometheus.yml"] - volumes: - - ./signoz/prometheus.yml:/root/config/prometheus.yml - - ./signoz/data/signoz/:/var/lib/signoz/ - environment: - - ClickHouseUrl=tcp://clickhouse:9000/?database=signoz_traces - - ALERTMANAGER_API_PREFIX=http://alertmanager:9093/api/ - - SIGNOZ_LOCAL_DB_PATH=/var/lib/signoz/signoz.db - - DASHBOARDS_PATH=/root/config/dashboards - - STORAGE=clickhouse - - GODEBUG=netdns=go - - TELEMETRY_ENABLED=true - - DEPLOYMENT_TYPE=docker-standalone-amd - restart: on-failure - healthcheck: - test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"] - interval: 30s - timeout: 5s - retries: 3 - depends_on: - clickhouse: - condition: service_healthy - - frontend: - image: signoz/frontend:${DOCKER_TAG:-0.22.0} - restart: on-failure - depends_on: - - alertmanager - - query-service - ports: - - 3301:3301 - volumes: - - ./signoz/common/nginx-config.conf:/etc/nginx/conf.d/default.conf - - signoz-otel-collector: - image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.2} - command: ["--config=/etc/otel-collector-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] - user: root # required for reading docker container logs - volumes: - - ./signoz/otel-collector-config.yaml:/etc/otel-collector-config.yaml - - /var/lib/docker/containers:/var/lib/docker/containers:ro - environment: - - OTEL_RESOURCE_ATTRIBUTES=host.name=signoz-host,os.type=linux - - DOCKER_MULTI_NODE_CLUSTER=false - - LOW_CARDINAL_EXCEPTION_GROUPING=false - restart: on-failure - depends_on: - clickhouse: - condition: service_healthy - - signoz-otel-collector-metrics: - image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.2} - command: ["--config=/etc/otel-collector-metrics-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] - volumes: - - ./signoz/otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml - restart: on-failure - depends_on: - clickhouse: - condition: service_healthy - # SigNoz End - - # Demo - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - ports: - - 5432:5432 - - demo-cache: - image: redis:6 - restart: unless-stopped - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 1s - timeout: 3s - retries: 60 - - demo-queue: - image: rabbitmq:3.8-management - restart: unless-stopped - healthcheck: - test: rabbitmq-diagnostics -q check_running - interval: 1s - timeout: 5s - retries: 60 - - demo-api: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: api - ports: - - "8081:8081" - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:8081"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - - demo-worker: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: worker - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - - demo-rpc: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: rpc - ports: - - 8082:8082 - healthcheck: - test: ["CMD", "lsof", "-i", "8082"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - # Demo End diff --git a/examples/tracetest-signoz-pokeshop/docker-compose.yaml b/examples/tracetest-signoz-pokeshop/docker-compose.yaml index b0666d292d..3e3243c659 100644 --- a/examples/tracetest-signoz-pokeshop/docker-compose.yaml +++ b/examples/tracetest-signoz-pokeshop/docker-compose.yaml @@ -1,42 +1,57 @@ version: "3" services: + 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 - tracetest: - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 + tracetest-apply: + build: + dockerfile: Dockerfile.tracetest volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" + - ./resources:/resources + environment: + TRACETEST_TOKEN: ${TRACETEST_TOKEN} + TRACETEST_ENVIRONMENT_ID: ${TRACETEST_ENVIRONMENT_ID} + entrypoint: + - bash + - /resources/apply.sh + networks: + default: null depends_on: - postgres: - condition: service_healthy otel-collector: condition: service_started - healthcheck: - test: [ "CMD", "wget", "--spider", "localhost:11633" ] - interval: 1s - timeout: 3s - retries: 60 + demo-api: + condition: service_healthy + tracetest-agent: + condition: service_started + + tracetest-run: + build: + dockerfile: Dockerfile.tracetest + volumes: + - ./resources:/resources environment: - TRACETEST_DEV: ${TRACETEST_DEV} + 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 otel-collector: - image: otel/opentelemetry-collector:0.54.0 + image: otel/opentelemetry-collector:0.101.0 command: - "--config" - "/otel-local-config.yaml" volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml + - ./collector.config.yaml:/otel-local-config.yaml ports: - 4317:4317 depends_on: @@ -70,7 +85,7 @@ services: max-size: 50m max-file: "3" healthcheck: - test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"] + test: ["CMD", "wget", "--spider", "-q", "0.0.0.0:8123/ping"] interval: 30s timeout: 5s retries: 3 @@ -155,7 +170,8 @@ services: signoz-otel-collector-metrics: image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.2} - command: ["--config=/etc/otel-collector-metrics-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] + command: + ["--config=/etc/otel-collector-metrics-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] volumes: - ./signoz/otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml restart: on-failure @@ -215,6 +231,8 @@ services: timeout: 3s retries: 60 depends_on: + demo-worker: + condition: service_started postgres: condition: service_healthy demo-cache: diff --git a/examples/tracetest-signoz-pokeshop/tests/curl_get.sh b/examples/tracetest-signoz-pokeshop/tests/curl_get.sh deleted file mode 100755 index 4d5faaf1b1..0000000000 --- a/examples/tracetest-signoz-pokeshop/tests/curl_get.sh +++ /dev/null @@ -1 +0,0 @@ -curl -d '' -H "Content-Type: application/json" -X GET http://localhost:8081/pokemon \ No newline at end of file diff --git a/examples/tracetest-signoz-pokeshop/tests/curl_post.sh b/examples/tracetest-signoz-pokeshop/tests/curl_post.sh deleted file mode 100755 index cdffda742f..0000000000 --- a/examples/tracetest-signoz-pokeshop/tests/curl_post.sh +++ /dev/null @@ -1 +0,0 @@ -curl -d '{"id":6}' -H "Content-Type: application/json" -X POST http://localhost:8081/pokemon/import \ No newline at end of file diff --git a/examples/tracetest-signoz-pokeshop/tests/test.yaml b/examples/tracetest-signoz-pokeshop/tests/test.yaml deleted file mode 100644 index aea25e1f3a..0000000000 --- a/examples/tracetest-signoz-pokeshop/tests/test.yaml +++ /dev/null @@ -1,32 +0,0 @@ -type: Test -spec: - id: ZVJwkpC4g - name: Pokeshop - Import - description: Import a Pokemon - trigger: - type: http - httpRequest: - method: POST - url: http://demo-api:8081/pokemon/import - body: '{"id":6}' - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http"] - name: "All HTTP Spans: Status code is 200" - assertions: - - attr:http.status_code = 200 - - selector: span[tracetest.span.type="general" name="import pokemon"] - name: Validate that this span always exists after the message queue - assertions: - - attr:tracetest.selected_spans.count = 1 - - attr:span.events not-contains "exception" - - selector: span[tracetest.span.type="database" name="get pokemon_6" db.system="redis" db.operation="get" db.redis.database_index="0"] - name: Validate that Redis is using Charizard. - assertions: - - attr:db.payload = '{"key":"pokemon_6"}' - - selector: span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres" db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"] - name: Validate that the Postgres has Charizard. - assertions: - - attr:db.result contains "charizard" diff --git a/examples/tracetest-signoz-pokeshop/tracetest/collector.config.yaml b/examples/tracetest-signoz-pokeshop/tracetest/collector.config.yaml deleted file mode 100644 index bc59998e2a..0000000000 --- a/examples/tracetest-signoz-pokeshop/tracetest/collector.config.yaml +++ /dev/null @@ -1,40 +0,0 @@ -receivers: - otlp: - protocols: - grpc: - http: - -processors: - batch: - timeout: 100ms - - # Data sources: traces - probabilistic_sampler: - hash_seed: 22 - sampling_percentage: 100 - -exporters: - # OTLP for Hobby Tracetest Core - otlp/tracetest: - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - endpoint: tracetest:4317 - tls: - insecure: true - # OTLP for Cloud-based Managed Tracetest - otlp/tracetest-agent: - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - endpoint: tracetest-agent:4317 - tls: - insecure: true - # OTLP for Signoz - otlp/signoz: - endpoint: signoz-otel-collector:4317 - tls: - insecure: true - -service: - pipelines: - traces: - receivers: [otlp] - processors: [probabilistic_sampler, batch] - exporters: [otlp/signoz,otlp/tracetest,otlp/tracetest-agent] diff --git a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-config.yaml b/examples/tracetest-signoz-pokeshop/tracetest/tracetest-config.yaml deleted file mode 100644 index 77fe974a60..0000000000 --- a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 # 100% - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector diff --git a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-provision.yaml b/examples/tracetest-signoz-pokeshop/tracetest/tracetest-provision.yaml deleted file mode 100644 index 8fd420e72a..0000000000 --- a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-provision.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 10m - ---- -type: DataStore -spec: - name: Signoz - type: signoz - ---- -type: TestRunner -spec: - id: current - name: default - requiredGates: - - analyzer-score - - test-specs - ---- -type: Demo -spec: - type: pokeshop - enabled: true - name: pokeshop - opentelemetryStore: {} - pokeshop: - httpEndpoint: http://demo-api:8081 - grpcEndpoint: demo-rpc:8082 diff --git a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-tracing-backend.yaml b/examples/tracetest-signoz-pokeshop/tracetest/tracetest-tracing-backend.yaml deleted file mode 100644 index 358a7e7e59..0000000000 --- a/examples/tracetest-signoz-pokeshop/tracetest/tracetest-tracing-backend.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -type: DataStore -spec: - id: current - name: Signoz - type: signoz From ded849f97181d43a4c1867e686856fe63fe0e0c4 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 11:05:00 -0600 Subject: [PATCH 09/12] updating signoz example --- .../Dockerfile.tracetest | 11 ++++++ .../collector.config.yaml | 34 +++++++++++++++++++ .../resources/apply.sh | 17 ++++++++++ .../resources/datastore.yaml | 6 ++++ .../resources/run.sh | 16 +++++++++ .../resources/test.yaml | 32 +++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 examples/tracetest-signoz-pokeshop/Dockerfile.tracetest create mode 100644 examples/tracetest-signoz-pokeshop/collector.config.yaml create mode 100644 examples/tracetest-signoz-pokeshop/resources/apply.sh create mode 100644 examples/tracetest-signoz-pokeshop/resources/datastore.yaml create mode 100644 examples/tracetest-signoz-pokeshop/resources/run.sh create mode 100644 examples/tracetest-signoz-pokeshop/resources/test.yaml diff --git a/examples/tracetest-signoz-pokeshop/Dockerfile.tracetest b/examples/tracetest-signoz-pokeshop/Dockerfile.tracetest new file mode 100644 index 0000000000..883f239155 --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/Dockerfile.tracetest @@ -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"] diff --git a/examples/tracetest-signoz-pokeshop/collector.config.yaml b/examples/tracetest-signoz-pokeshop/collector.config.yaml new file mode 100644 index 0000000000..8708e952f8 --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/collector.config.yaml @@ -0,0 +1,34 @@ +receivers: + otlp: + protocols: + grpc: + http: + +processors: + batch: + timeout: 100ms + + # Data sources: traces + probabilistic_sampler: + hash_seed: 22 + sampling_percentage: 100 + +exporters: + # OTLP for Cloud-based Managed Tracetest + otlp/tracetest-agent: + # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 + tls: + insecure: true + # OTLP for Signoz + otlp/signoz: + endpoint: signoz-otel-collector:4317 + tls: + insecure: true + +service: + pipelines: + traces: + receivers: [otlp] + processors: [probabilistic_sampler, batch] + exporters: [otlp/signoz, otlp/tracetest-agent] diff --git a/examples/tracetest-signoz-pokeshop/resources/apply.sh b/examples/tracetest-signoz-pokeshop/resources/apply.sh new file mode 100644 index 0000000000..13b878ba47 --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/resources/apply.sh @@ -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 diff --git a/examples/tracetest-signoz-pokeshop/resources/datastore.yaml b/examples/tracetest-signoz-pokeshop/resources/datastore.yaml new file mode 100644 index 0000000000..358a7e7e59 --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/resources/datastore.yaml @@ -0,0 +1,6 @@ +--- +type: DataStore +spec: + id: current + name: Signoz + type: signoz diff --git a/examples/tracetest-signoz-pokeshop/resources/run.sh b/examples/tracetest-signoz-pokeshop/resources/run.sh new file mode 100644 index 0000000000..05d0f41724 --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/resources/run.sh @@ -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 diff --git a/examples/tracetest-signoz-pokeshop/resources/test.yaml b/examples/tracetest-signoz-pokeshop/resources/test.yaml new file mode 100644 index 0000000000..aea25e1f3a --- /dev/null +++ b/examples/tracetest-signoz-pokeshop/resources/test.yaml @@ -0,0 +1,32 @@ +type: Test +spec: + id: ZVJwkpC4g + name: Pokeshop - Import + description: Import a Pokemon + trigger: + type: http + httpRequest: + method: POST + url: http://demo-api:8081/pokemon/import + body: '{"id":6}' + headers: + - key: Content-Type + value: application/json + specs: + - selector: span[tracetest.span.type="http"] + name: "All HTTP Spans: Status code is 200" + assertions: + - attr:http.status_code = 200 + - selector: span[tracetest.span.type="general" name="import pokemon"] + name: Validate that this span always exists after the message queue + assertions: + - attr:tracetest.selected_spans.count = 1 + - attr:span.events not-contains "exception" + - selector: span[tracetest.span.type="database" name="get pokemon_6" db.system="redis" db.operation="get" db.redis.database_index="0"] + name: Validate that Redis is using Charizard. + assertions: + - attr:db.payload = '{"key":"pokemon_6"}' + - selector: span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres" db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"] + name: Validate that the Postgres has Charizard. + assertions: + - attr:db.result contains "charizard" From 426637366994f50a21fbbe6812e98923cd4993ea Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 11:05:14 -0600 Subject: [PATCH 10/12] PR suggestions updates --- examples/tracetest-dynatrace/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/tracetest-dynatrace/.gitignore diff --git a/examples/tracetest-dynatrace/.gitignore b/examples/tracetest-dynatrace/.gitignore new file mode 100644 index 0000000000..4c49bd78f1 --- /dev/null +++ b/examples/tracetest-dynatrace/.gitignore @@ -0,0 +1 @@ +.env From 5e04b7e194ea2c5392e77c5a767960f58ecfc694 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Wed, 14 Aug 2024 11:31:43 -0600 Subject: [PATCH 11/12] updating recipes --- .../running-tracetest-with-datadog.mdx | 298 +++----- .../running-tracetest-with-dynatrace.mdx | 239 +----- .../running-tracetest-with-honeycomb.mdx | 405 +---------- .../running-tracetest-with-lightstep.mdx | 216 +----- .../running-tracetest-with-new-relic.mdx | 248 ++----- ...running-tracetest-with-signoz-pokeshop.mdx | 686 +----------------- 6 files changed, 257 insertions(+), 1835 deletions(-) diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx index 52d2ce84cd..56a304b647 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx @@ -26,7 +26,33 @@ This is a simple sample app on how to configure the [OpenTelemetry Demo `v1.3.0` ## Prerequisites -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this sample app! Additionally, you will need a Datadog account and an API. Sign up to Datadog on their [homepage](https://www.datadoghq.com/) by clicking on `Get Started Free`. +**Tracetest Account**: + +- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. +- 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. + +## Run This Quckstart Example + +The example below is provided as part of the Tracetest project. You can download and run the example by following these steps: + +Clone the Tracetest project and go to the example folder: + +```bash +git clone https://github.com/kubeshop/tracetest +cd tracetest/examples/tracetest-datadog +``` + +Follow these instructions to run the quick start: + +1. Copy the `.env.template` file to `.env`. +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 [DATADOG_API_KEY](https://www.datadoghq.com/) 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. ## Project Structure @@ -36,17 +62,10 @@ The project is built with Docker Compose. It contains two distinct `docker-compo The `docker-compose.yaml` file and `.env` file in the root directory are for the OpenTelemetry Demo. -### 2. Tracetest - -The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for setting up Tracetest and the OpenTelemetry Collector. - -The `tracetest` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest, as well as routing all traces the OpenTelemetry Demo generates to Datadog. - ### Docker Compose Network All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where port `4317` is the port where Tracetest accepts traces. - ## OpenTelemetry Demo The [OpenDelemetry Demo](https://github.com/open-telemetry/opentelemetry-demo) is a sample microservice-based app with the purpose to demo how to correctly set up OpenTelemetry distributed tracing. @@ -63,153 +82,11 @@ docker compose up This will start the OpenTelemetry Demo. Open up `http://localhost:8084` to make sure it's working. But, you're not sending the traces anywhere. -Let's fix this by configuring Tracetest and the OpenTelemetry Collector to forward trace data to both Lightstep and Tracetest. - -## Tracetest - -The `docker-compose.yaml` in the `tracetest` directory is configured with three services. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running trace-based tests. -- [**OpenTelemetry Collector**](https://opentelemetry.io/docs/collector/) - A vendor-agnostic implementation of how to receive, process and export telemetry data. To support sending traces to Datadog, we are using the [`contrib` version](https://github.com/open-telemetry/opentelemetry-collector-contrib), which contains vendor-related code. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3.9" - -networks: - default: - name: opentelemetry-demo - driver: bridge - -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - container_name: tracetest - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest-provision.yaml - target: /app/provisioning.yaml - command: --provisioning-file /app/provisioning.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - tt-postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - tt-postgres: - image: postgres:14 - container_name: tt-postgres - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - container_name: otel-collector - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml - -``` - -Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files. - -To start both the OpenTelemetry Demo and Tracetest we will run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance and telemetry exporter. The exporter is set to the OpenTelemetry Collector. - -```yaml -# tracetest-config.yaml - ---- -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector -``` - -The `tracetest-provision.yaml` file contains the setup of the demo APIs that Tracetest can use as an example for tests, the polling profiles that say how Tracetest should fetch traces from the data store and the configuration for the data store, in our case, Datadog. - -```yaml ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://frontend:8084 - productCatalogEndpoint: productcatalogservice:3550 - cartEndpoint: cartservice:7070 - checkoutEndpoint: checkoutservice:5050 - ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 180s - ---- -type: DataStore -spec: - name: datadog - type: datadog - -``` +Let's fix this by configuring Tracetest and the OpenTelemetry Collector to forward trace data to both Datadog and Tracetest. **Sending Traces to Tracetest and Datadog** -The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Datadog in another. +The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's Agent OTLP endpoint `tracetest-agent:4317` in one pipeline, and to Datadog in another. Make sure to add your Datadog API Key to the `datadog` exporter. @@ -219,6 +96,35 @@ receivers: protocols: http: grpc: + # The hostmetrics receiver is required to get correct infrastructure metrics in Datadog. + hostmetrics: + collection_interval: 10s + scrapers: + paging: + metrics: + system.paging.utilization: + enabled: true + cpu: + metrics: + system.cpu.utilization: + enabled: true + disk: + filesystem: + metrics: + system.filesystem.utilization: + enabled: true + load: + memory: + network: + processes: + # The prometheus receiver scrapes metrics needed for the OpenTelemetry Collector Dashboard. + prometheus: + config: + scrape_configs: + - job_name: 'otelcol' + scrape_interval: 10s + static_configs: + - targets: ['0.0.0.0:8888'] processors: batch: # this configuration is needed to guarantee that the data is sent correctly to Datadog @@ -229,18 +135,16 @@ processors: exporters: # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 - # Send traces to Tracetest. - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # Datadog exporter + # One example on how to set up a collector configuration for Datadog can be seen here: + # https://docs.datadoghq.com/opentelemetry/otel_collector_datadog_exporter/?tab=onahost datadog: api: site: datadoghq.com - key: ${DATADOG_API_KEY} # Add here you API key for Datadog - # One example on how to set up a collector configuration for Datadog can be seen here: - # https://docs.datadoghq.com/opentelemetry/otel_collector_datadog_exporter/?tab=onahost + key: ${env:DATADOG_API_KEY} # Add here you API key for Datadog service: pipelines: @@ -252,52 +156,20 @@ service: receivers: [otlp] processors: [batch] exporters: [datadog] + metrics: + receivers: [hostmetrics, otlp] + processors: [batch] + exporters: [datadog] ``` -## Run Both the OpenTelemetry Demo App and Tracetest - -To start both OpenTelemetry and Tracetest, run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up -``` - -This will start your Tracetest instance on `http://localhost:11633/`. - -Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the endpoints within your Docker network like `http://frontend:8084/` when creating tests. - -This is because your OpenTelemetry Demo and Tracetest are in the same network. - -> Note: View the `demo` section in the `tracetest.config.yaml` to see which endpoints from the OpenTelemetry Demo are available for running tests. - -Here's a sample of a failed test run, which happens if you add this assertion: - -```css -attr:tracetest.span.duration < 10ms -``` - -![](../img/datadog-recipe-failed-test.png) - -Increasing the duration to a more reasonable `500ms` will make the test pass. - -![](../img/datadog-recipe-successful-test.png) +## Running the tests -## Run Tracetest Tests with the Tracetest CLI +### The Test File -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: - -```bash -tracetest configure --server-url http://localhost:11633 -``` - -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `http-test.yaml` file. +Check out the `resources/test.yaml` file. ```yaml -# http-test.yaml - +# resources/test.yaml type: Test spec: id: JBYAfKJ4R @@ -325,32 +197,28 @@ spec: - attr:rpc.grpc.status_code = 0 ``` -This file defines a test the same way you would through the Web UI. - To run the test, run this command in the terminal: ```bash -tracetest run test -f ./http-test.yaml +docker compose run tracetest-run ``` -This test will fail just like the sample above due to the `attr:tracetest.span.duration < 10ms` assertion. +This test will fail just like the sample above due to the `attr:tracetest.span.duration < 50ms` assertion. ```bash -✘ OpenTelemetry Shop - List Products (http://localhost:11633/test/JBYAfKJ4R/run/3/test) - ✘ span[tracetest.span.type="general" name="Tracetest trigger"] - ✘ #2d1b0dcbd75b3a42 - ✔ attr:tracetest.response.status = 200 (200) - ✘ attr:tracetest.span.duration < 10ms (24ms) (http://localhost:11633/test/JBYAfKJ4R/run/3/test?selectedAssertion=0&selectedSpan=2d1b0dcbd75b3a42) - ✔ span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] - ✔ #90aeab1e9db4617b - ✔ attr:rpc.grpc.status_code = 0 (http://localhost:11633/test/JBYAfKJ4R/run/3/test?selectedAssertion=1) - ✔ span[tracetest.span.type="rpc" name="hipstershop.ProductCatalogService/ListProducts" rpc.system="grpc" rpc.method="ListProducts" rpc.service="hipstershop.ProductCatalogService"] - ✔ #44b836b092b4d708 - ✔ attr:rpc.grpc.status_code = 0 (http://localhost:11633/test/JBYAfKJ4R/run/3/test?selectedAssertion=2) +✘ Otel - List Products (http://localhost:11633/test/YJmFC7hVg/run/9/test) + ✘ span[tracetest.span.type="http" name="API HTTP GET" http.target="/api/products" http.method="GET"] + ✘ #cb68ccf586956db7 + ✔ attr:http.status_code = 200 (200) + ✘ attr:tracetest.span.duration < 50ms (72ms) (http://localhost:11633/test/YJmFC7hVg/run/9/test?selectedAssertion=0&selectedSpan=cb68ccf586956db7) + ✔ span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] + ✔ #634f965d1b34c1fd + ✔ attr:rpc.grpc.status_code = 0 (0) + ✔ span[tracetest.span.type="rpc" name="hipstershop.ProductCatalogService/ListProducts" rpc.system="grpc" rpc.method="ListProducts" rpc.service="hipstershop.ProductCatalogService"] + ✔ #33a58e95448d8b22 + ✔ attr:rpc.grpc.status_code = 0 (0) ``` -If you edit the duration as in the Web UI example above, the test will pass! - ## View Trace Spans Over Time in Datadog To access a historical overview of all the trace spans the OpenTelemetry Demo generates, jump over to your Datadog account on `APM > Traces` area. diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx index b482d3c7ac..0a4ae0b10c 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx @@ -26,7 +26,33 @@ This is a simple sample app on how to configure the [OpenTelemetry Demo `v1.3.0` ## Prerequisites -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this sample app! Additionally, you will need a Dynatrace account and an API token. Sign up for a [free Dynatrace trial](https://www.dynatrace.com/trial). +**Tracetest Account**: + +- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. +- 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. + +## Run This Quckstart Example + +The example below is provided as part of the Tracetest project. You can download and run the example by following these steps: + +Clone the Tracetest project and go to the example folder: + +```bash +git clone https://github.com/kubeshop/tracetest +cd tracetest/examples/tracetest-dynatrace +``` + +Follow these instructions to run the quick start: + +1. Copy the `.env.template` file to `.env`. +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 [DYNATRACE_SECRET](https://www.dynatrace.com/) 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. ## Project Structure @@ -40,8 +66,6 @@ The `docker-compose.yaml` file and `.env` file in the root directory are for the The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for setting up Tracetest and the OpenTelemetry Collector. -The `tracetest` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest, as well as routing all traces the OpenTelemetry Demo generates to Dynatrace. - ### Docker Compose Network All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where port `4317` is the port where Tracetest accepts traces. @@ -64,156 +88,6 @@ This will start the OpenTelemetry Demo. Open up `http://localhost:8084` to make Let's fix this by configuring Tracetest and the OpenTelemetry Collector to forward trace data to both Dynatrace and Tracetest. -## Tracetest - -The `docker-compose.yaml` in the `tracetest` directory is configured with three services. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running trace-based tests. -- [**OpenTelemetry Collector**](https://opentelemetry.io/docs/collector/) - A vendor-agnostic implementation of how to receive, process and export telemetry data. To support sending traces to Dynatrace, we are using the [`contrib` version](https://github.com/open-telemetry/opentelemetry-collector-contrib), which contains vendor-related code. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3.9" - -networks: - default: - name: opentelemetry-demo - driver: bridge - -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - container_name: tracetest - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provisioning.yaml - command: --provisioning-file /app/provisioning.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - tt-postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - tt-postgres: - image: postgres:14 - container_name: tt-postgres - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.82.0 - container_name: otel-collector - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml -``` - -Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files. - -To start both the OpenTelemetry Demo and Tracetest we will run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance and telemetry exporter. The exporter is set to the OpenTelemetry Collector. - -```yaml -# tracetest-config.yaml - ---- -postgres: - host: tt-postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector -``` - -The `tracetest-provision.yaml` file contains the setup of the demo APIs that Tracetest can use as an example for tests, the polling profiles that say how Tracetest should fetch traces from the data store and the configuration for the data store, in our case, Dynatrace. - -```yaml ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://frontend:8084 - productCatalogEndpoint: productcatalogservice:3550 - cartEndpoint: cartservice:7070 - checkoutEndpoint: checkoutservice:5050 - ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 10m - ---- -type: DataStore -spec: - name: Dynatrace - type: dynatrace - ---- -type: TestRunner -spec: - id: current - name: default - requiredGates: - - analyzer-score - - test-specs - -``` - ### Sending Traces to Tracetest and Dynatrace The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Dynatrace in another. @@ -256,7 +130,7 @@ receivers: - targets: ['0.0.0.0:8888'] processors: - batch: # this configuration is needed to guarantee that the data is sent correctly to Dynatrace + batch: # this configuration is needed to guarantee that the data is sent correctly to Datadog send_batch_max_size: 100 send_batch_size: 10 timeout: 10s @@ -264,15 +138,14 @@ processors: exporters: # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # OTLP for Dynatrace otlphttp/dynatrace: endpoint: https://abc12345.live.dynatrace.com/api/v2/otlp headers: - Authorization: "Api-Token dt0c01.sample.secret" # Requires "openTelemetryTrace.ingest" permission + Authorization: "Api-Token ${DYNATRACE_SECRET}" # Requires "openTelemetryTrace.ingest" permission service: pipelines: @@ -290,54 +163,14 @@ service: exporters: [otlphttp/dynatrace] ``` -## Run Both the OpenTelemetry Demo App and Tracetest - -To start both OpenTelemetry and Tracetest, run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up -``` - -:::note Heads up! -Please note starting the demo for the first time will take a few minutes. -::: - -This will start your Tracetest instance on `http://localhost:11633/`. - -Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the endpoints within your Docker network like `http://frontend:8084/` when creating tests. - -This is because your OpenTelemetry Demo and Tracetest are in the same network. - -> Note: View the `demo` section in the `tracetest.config.yaml` to see which endpoints from the OpenTelemetry Demo are available for running tests. - -Here's a sample of a failed test run, which happens if you add this assertion: - -```css -attr:tracetest.span.duration < 10ms -``` - -![](../img/dynatrace-failed-test.png) - -Increasing the duration to a more reasonable `500ms` will make the test pass. +## Running the tests -![](../img/dynatrace-successful-test.png) +### The Test File -## Run Tracetest Tests with the Tracetest CLI - -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: - -```bash -tracetest configure --server-url http://localhost:11633 -``` - -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `http-test.yaml` file. +Check out the `resources/test.yaml` file. ```yaml -# http-test.yaml - +# resources/test.yaml type: Test spec: id: JBYAfKJ4R @@ -365,12 +198,10 @@ spec: - attr:rpc.grpc.status_code = 0 ``` -This file defines a test the same way you would through the Web UI. - To run the test, run this command in the terminal: ```bash -tracetest run test -f ./http-test.yaml +docker compose run tracetest-run ``` This test will fail just like the sample above due to the `attr:tracetest.span.duration < 10ms` assertion. diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-honeycomb.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-honeycomb.mdx index 27079de3d5..706792ffee 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-honeycomb.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-honeycomb.mdx @@ -18,10 +18,6 @@ keywords: image: https://res.cloudinary.com/djwdcmwdz/image/upload/v1698686403/docs/Blog_Thumbnail_14_rsvkmo.jpg --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import CodeBlock from '@theme/CodeBlock'; - :::note [Check out the source code on GitHub here.](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-honeycomb) ::: @@ -34,19 +30,12 @@ import CodeBlock from '@theme/CodeBlock'; This is a quick start on how to configure a Node.js app to use OpenTelemetry instrumentation with traces, and Tracetest for enhancing your E2E and integration tests with trace-based testing and Honeycomb as a trace data store. -```mdx-code-block - - -``` - ## Prerequisites **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,11 +53,10 @@ cd tracetest/examples/tracetest-honeycomb 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. This example is configured to use the Honeycomb Tracing Backend. Ensure the environment you will be utilizing to run this example is also configured to use the Honeycomb Tracing Backend by clicking on Settings, Tracing Backend, Honeycomb, Save. -4. 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. -5. Run `docker compose -f ./docker-compose.agent.yaml up -d`. -6. Run tests from the Tracetest Web UI by accessing the app with the URL `http://app:8080/`. +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 [HONEYCOMB_API_KEY](https://www.honeycomb.io/) 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 a detailed breakdown of what the example you just ran did and how it works. @@ -85,7 +73,11 @@ The Node.js app is a simple Express app, contained in the `app.js` file. Configure the `.env` like shown below. ```bash -TRACETEST_API_KEY="" +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" + HONEYCOMB_API_KEY="" ``` @@ -101,380 +93,19 @@ Enabling the tracer is done by preloading the trace file. As seen in the `packag }, ``` -## Configuring Honeycomb - -Configure [Honeycomb as a Tracing Backend](/configuration/connecting-to-data-stores/honeycomb) in Tracetest. - -```yaml title="tracetest-tracing-backend.yaml" ---- -type: DataStore -spec: - name: Honeycomb - type: honeycomb - default: true -``` - -```bash -tracetest config -t -tracetest apply datastore -f ./tracetest-tracing-backend.yaml -``` - -## Run the Node.js App, OpenTelemetry Collector, and Tracetest Agent with Docker Compose - -To start the full setup, run the following command: - -```bash -docker compose -f ./docker-compose.agent.yaml up -d -``` - -## Run Tracetest Tests +### Run Tracetest Tests -1. Open [Tracetest](https://app.tracetest.io/). -2. [Configure Honeycomb as a tracing backend](/configuration/connecting-to-data-stores/honeycomb) 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: +To execute the tests, run this command: ```bash -tracetest configure -t -tracetest run test -f ./test-api.yaml -``` - -```mdx-code-block - - +docker compose run tracetest-run ``` -## Prerequisites - -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this sample app! Additionally, you will need a Honeycomb account and api key. Sign up to use Honeycomb [here](https://ui.honeycomb.io/signup). - -## Project Structure - -The project is built with Docker Compose. It contains two distinct `docker-compose.yaml` files. - -### 1. Node.js App - -The `docker-compose.yaml` file and `Dockerfile` in the root directory are for the Node.js app. - -### 2. Tracetest - -The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the root directory are for the setting up Tracetest and the OpenTelemetry Collector. - -The `root` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest, as well as routing all traces the Node.js App generates to Honeycomb. - -### Docker Compose Network - -All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where the port `4317` is the port where Tracetest accepts traces. - -## Node.js App - -The Node.js app is a simple Express app contained in the `app.js` file. - -The OpenTelemetry tracing is contained in the `tracing.otel.grpc.js` or `tracing.otel.http.js` files. -Traces will be sent to the OpenTelemetry Collector. - -Here's the content of the `tracing.otel.grpc.js` file: - -```js -const opentelemetry = require("@opentelemetry/sdk-node"); -const { - getNodeAutoInstrumentations, -} = require("@opentelemetry/auto-instrumentations-node"); -const { - OTLPTraceExporter, -} = require("@opentelemetry/exporter-trace-otlp-grpc"); - -const sdk = new opentelemetry.NodeSDK({ - traceExporter: new OTLPTraceExporter({ url: "http://otel-collector:4317" }), - instrumentations: [getNodeAutoInstrumentations()], -}); -sdk.start(); -``` - -Depending on which of these you choose, traces will be sent to either the `grpc` or `http` endpoint. - -The hostnames and ports for these are: - -- GRPC: `http://otel-collector:4317` -- HTTP: `http://otel-collector:4318/v1/traces` - -Enabling the tracer is done by preloading the trace file. - -```bash -node -r ./tracing.otel.grpc.js app.js -``` - -In the `package.json` you will see two npm scripts for running the respective tracers alongside the `app.js`. - -```json -"scripts": { - "with-grpc-tracer":"node -r ./tracing.otel.grpc.js app.js", - "with-http-tracer":"node -r ./tracing.otel.http.js app.js" -}, -``` - -To start the server, run this command: - -```bash -npm run with-grpc-tracer -# or -npm run with-http-tracer -``` - -As you can see the `Dockerfile` uses the command above. - -```Dockerfile -FROM node:slim -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -EXPOSE 8080 -CMD [ "npm", "run", "with-grpc-tracer" ] -``` - -And, the `docker-compose.yaml` contains just one service for the Node.js app. - -```yaml -version: "3" -services: - app: - image: quick-start-nodejs - build: . - ports: - - "8080:8080" -``` - -To start it, run this command: - -```bash -docker compose build # optional if you haven't already built the image -docker compose up -``` - -This will start the Node.js app. But, you're not sending the traces anywhere. - -Let's fix this by configuring Tracetest and OpenTelemetry Collector. - -## Tracetest - -The `docker-compose.yaml` in the `tracetest` directory is configured with three services. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running the trace-based tests. -- [**OpenTelemetry Collector**](https://opentelemetry.io/docs/collector/) - A vendor-agnostic implementation of how to receive, process and export telemetry data. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3.2" -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml - -``` - -Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files. - -To start both the Node.js App and Tracetest, run this command: - -```bash -docker-compose up # add --build if the images are not built already -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance. - -```yaml -# tracetest-config.yaml - ---- -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -``` - -The `tracetest-provision.yaml` file contains the data store setup. The data store is set to `Honeycomb` meaning the traces will be received by Tracetest OTLP API and stored in Tracetest itself. - -```yaml -# tracetest-provision.yaml ---- -type: DataStore -spec: - name: Honeycomb - type: honeycomb -``` - -**How to Send Traces to Tracetest and Honeycomb** - -The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Honeycomb in another. - -Make sure to add your Honeycomb access token in the headers of the `otlp/ls` exporter. - -```yaml -receivers: - otlp: - protocols: - grpc: - http: - -processors: - batch: - timeout: 100ms - -exporters: - logging: - logLevel: debug - # OTLP for Tracetest - otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - tls: - insecure: true - # OTLP for Honeycomb - otlp/honeycomb: - endpoint: "api.honeycomb.io:443" - headers: - "x-honeycomb-team": - # Read more in docs here: https://docs.honeycomb.io/getting-data-in/otel-collector/ - -service: - pipelines: - traces/tracetest: - receivers: [otlp] - processors: [batch] - exporters: [otlp/tracetest] - traces/honeycomb: - receivers: [otlp] - processors: [batch] - exporters: [logging, otlp/honeycomb] -``` - -## Run Both the Node.js App and Tracetest - -To start both the Node.js App and Tracetest, run this command: - -```bash -docker-compose up # add --build if the images are not built already -``` - -This will start your Tracetest instance on `http://localhost:11633/`. - -Open the URL and start creating tests! Make sure to use the `http://app:8080/` URL in your test creation, because your Node.js app and Tracetest are in the same network. - -## Run Tracetest Tests with the Tracetest CLI - -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: - -```bash -tracetest configure --server-url http://localhost:11633 -``` - -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `test-api.yaml` file. - -```yaml -# test-api.yaml - -type: Test -spec: - id: W656Q0c4g - name: http://app:8080 - description: akadlkasjdf - trigger: - type: http - httpRequest: - url: http://app:8080 - method: GET - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http" name="GET /" http.target="/" http.method="GET"] - assertions: - - attr:http.status_code = 200 - - attr:tracetest.span.duration < 500ms - -``` - -This file defines a test the same way you would through the Web UI. - -To run the test, run this command in the terminal: - -```bash -tracetest run test -f ./test-api.yaml -``` - -```bash -✔ http://app:8080 (http://localhost:11633/test/W656Q0c4g/run/2/test) - ✔ span[tracetest.span.type="http" name="GET /" http.target="/" http.method="GET"] -``` - -## View Trace Spans Over Time in Honeycomb - -To access a historical overview of all the trace spans the Node.js App generates, jump over to your Honeycomb account. - -![Honeycomb trace overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1683042900/Blogposts/Docs/honeycomb_trace_kbjdl4.png) - -You can also drill down into a particular trace. - -![Honeycomb trace drilldown](https://res.cloudinary.com/djwdcmwdz/image/upload/v1683042900/Blogposts/Docs/honeycome_dashboard_gyisdg.png) - -With Honeycomb and Tracetest, you get the best of both worlds. You can run trace-based tests and automate running E2E and integration tests against real trace data. And, use Honeycomb to get a historical overview of all traces your distributed application generates. - -```mdx-code-block - - -``` +This will: +1. Start the Node.js app, the OpenTelemetry Collector, and send the traces to Honeycomb. +2. Start the Tracetest Agent. +3. Configure the tracing backend and create tests in your environment. +4. Run the tests. ## Learn More diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx index 612bf455a8..186165d554 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx @@ -26,7 +26,33 @@ This is a simple sample app on how to configure the [OpenTelemetry Demo `v0.3.4- ## Prerequisites -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this sample app! Additionally, you will need a Lightstep account and access token. Sign up to use Lightstep [here](https://app.lightstep.com/signup/developer). +**Tracetest Account**: + +- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. +- 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. + +## Run This Quckstart Example + +The example below is provided as part of the Tracetest project. You can download and run the example by following these steps: + +Clone the Tracetest project and go to the example folder: + +```bash +git clone https://github.com/kubeshop/tracetest +cd tracetest/examples/tracetest-lightstep +``` + +Follow these instructions to run the quick start: + +1. Copy the `.env.template` file to `.env`. +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 [LIGHTSTEP_ACCESS_TOKEN](https://docs.lightstep.com/otel/otel-quick-start) 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. ## Project Structure @@ -36,15 +62,9 @@ The project is built with Docker Compose. It contains two distinct `docker-compo The `docker-compose.yaml` file and `.env` file in the root directory are for the OpenTelemetry Demo. -### 2. Tracetest - -The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for the setting up Tracetest and the OpenTelemetry Collector. - -The `tracetest` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest, as well as routing all traces the OpenTelemetry Demo generates to Lightstep. - ### Docker Compose Network -All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where the port `4317` is the port where Tracetest accepts traces. +All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest-agent:4317` in the `collector.config.yaml` will map to the `tracetest-agent` service, where the port `4317` is the port where Tracetest accepts traces. ## OpenTelemetry Demo @@ -65,131 +85,6 @@ This will start the OpenTelemetry Demo. Open up `http://localhost:8084` to make Let's fix this by configuring Tracetest and OpenTelemetry Collector to forward trace data to both Lightstep and Tracetest. -## Tracetest - -The `docker-compose.yaml` in the `tracetest` directory is configured with three services. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running the trace-based tests. -- [**OpenTelemetry Collector**](https://opentelemetry.io/docs/collector/) - A vendor-agnostic implementation of how to receive, process and export telemetry data. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3.2" -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml - -``` - -Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files. - -To start both the OpenTelemetry Demo and Tracetest, run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up # add --build if the images are not built already -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance and defining the exporter. The exporter is set to the OpenTelemetry Collector. - -```yaml -# tracetest-config.yaml - ---- -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector - -``` - -The `tracetest-provision.yaml` file contains the data store setup. The data store is set to `lightstep` meaning the traces will be received by Tracetest OTLP API and stored in Tracetest itself. - -```yaml -# tracetest-provision.yaml ---- -type: DataStore -spec: - name: Lightstep - type: lightstep - ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://otel-frontend:8084 - productCatalogEndpoint: otel-productcatalogservice:3550 - cartEndpoint: otel-cartservice:7070 - checkoutEndpoint: otel-checkoutservice:5050 - -``` - **How to Send Traces to Tracetest and Lightstep** The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Lightstep in another. @@ -208,18 +103,16 @@ processors: timeout: 100ms exporters: - logging: - logLevel: debug # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 tls: insecure: true # OTLP for Lightstep otlp/lightstep: endpoint: ingest.lightstep.com:443 headers: - "lightstep-access-token": "" # Send traces to Lightstep. Read more in docs here: https://docs.lightstep.com/otel/otel-quick-start + "lightstep-access-token": ${env:LIGHTSTEP_ACCESS_TOKEN} # Send traces to Lightstep. Read more in docs here: https://docs.lightstep.com/otel/otel-quick-start service: pipelines: @@ -230,52 +123,17 @@ service: traces/lightstep: receivers: [otlp] processors: [batch] - exporters: [logging, otlp/lightstep] -``` - -## Run Both the OpenTelemetry Demo App and Tracetest - -To start both the OpenTelemetry and Tracetest, run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up # add --build if the images are not built already + exporters: [otlp/lightstep] ``` -This will start your Tracetest instance on `http://localhost:11633/`. +## Running the tests -Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the endpoints within your Docker network like `http://otel-frontend:8084/` when creating tests. +### The Test File -This is because your OpenTelemetry Demo and Tracetest are in the same network. - -> Note: View the `demo` section in the `tracetest.config.yaml` to see which endpoints from the OpenTelemetry Demo are available for running tests. - -Here's a sample of a failed test run, which happens if you add this assertion: - -```css -attr:tracetest.span.duration < 50ms -``` - -![failing test](https://res.cloudinary.com/djwdcmwdz/image/upload/v1672998179/Blogposts/tracetest-lightstep-partnership/screely-1672998159326_depw45.png) - -Increasing the duration to a more reasonable `500ms` will make the test pass. - -![passing test](https://res.cloudinary.com/djwdcmwdz/image/upload/v1672998252/Blogposts/tracetest-lightstep-partnership/screely-1672998249450_mngghb.png) - -## Run Tracetest Tests with the Tracetest CLI - -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: - -```bash -tracetest configure --server-url http://localhost:11633 -``` - -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `http-test.yaml` file. +Check out the `resources/test.yaml` file. ```yaml -# http-test.yaml +# resources/test.yaml type: Test spec: @@ -307,12 +165,10 @@ spec: - attr:rpc.grpc.status_code = 0 ``` -This file defines the a test the same way you would through the Web UI. - To run the test, run this command in the terminal: ```bash -tracetest run test -f ./http-test.yaml +docker compose run tracetest-run ``` This test will fail just like the sample above due to the `attr:tracetest.span.duration < 50ms` assertion. diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx index 59d7cdb194..8089fc0956 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx @@ -26,7 +26,33 @@ This is a simple sample app on how to configure the [OpenTelemetry Demo `v0.3.4- ## Prerequisites -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this sample app! Additionally, you will need a New Relic account and ingest licence key. Sign up to New Relic [here](https://newrelic.com/signup). +**Tracetest Account**: + +- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/installation) docs. +- 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. + +## Run This Quckstart Example + +The example below is provided as part of the Tracetest project. You can download and run the example by following these steps: + +Clone the Tracetest project and go to the example folder: + +```bash +git clone https://github.com/kubeshop/tracetest +cd tracetest/examples/tracetest-new-relic +``` + +Follow these instructions to run the quick start: + +1. Copy the `.env.template` file to `.env`. +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 [NEW_RELIC_INGEST_LICENSE](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-setup/#collector-export) 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. ## Project Structure @@ -36,12 +62,6 @@ The project is built with Docker Compose. It contains two distinct `docker-compo The `docker-compose.yaml` file and `.env` file in the root directory are for the OpenTelemetry Demo. -### 2. Tracetest - -The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for the setting up Tracetest and the OpenTelemetry Collector. - -The `tracetest` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest, as well as routing all traces the OpenTelemetry Demo generates to New Relic. - ### Docker Compose Network All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where the port `4317` is the port where Tracetest accepts traces. @@ -65,143 +85,10 @@ This will start the OpenTelemetry Demo. Open up `http://localhost:8084` to make Let's fix this by configuring Tracetest and OpenTelemetry Collector to forward trace data to both New Relic and Tracetest. -## Tracetest - -The `docker-compose.yaml` in the `tracetest` directory is configured with three services. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running the trace-based tests. -- [**OpenTelemetry Collector**](https://opentelemetry.io/docs/collector/) - A vendor-agnostic implementation of how to receive, process and export telemetry data. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3.2" -services: - tracetest: - restart: unless-stopped - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:11633"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 - restart: unless-stopped - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml -``` - -Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files. - -To start both the OpenTelemetry Demo and Tracetest, run this command: - -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up # add --build if the images are not built already -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance, and defining the exporter. The exporter is set to the OpenTelemetry Collector. - -```yaml -# tracetest-config.yaml -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector -``` - -The `tracetest-provision.yaml` file contains the data store setup. The data store is set to `newrelic` meaning the traces will be received by Tracetest OTLP API and stored in Tracetest itself. - -```yaml -# tracetest-provision.yaml ---- -type: DataStore -spec: - name: New Relic - type: newrelic - default: true - ---- -type: Demo -spec: - name: "OpenTelemetry Shop" - enabled: true - type: otelstore - opentelemetryStore: - frontendEndpoint: http://otel-frontend:8084 - productCatalogEndpoint: otel-productcatalogservice:3550 - cartEndpoint: otel-cartservice:7070 - checkoutEndpoint: otel-checkoutservice:5050 -``` - -**How to Send Traces to Tracetest and New Relic** - -The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to New Relic in another. - -Make sure to add your New Relic ingest licence key in the headers of the `otlp/newrelic` exporter. -You access the licence key in your New Relic account settings. - -![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1673009509/Blogposts/tracetest-new-relic-partnerships/screely-1673009504630_gko3up.png) - -You can find which ingest endpoint to use in the New Relic docs, [here](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-setup/#review-settings). - Here's how to configure the OpenTelemetry Collector. ```yaml # collector.config.yaml - receivers: otlp: protocols: @@ -213,18 +100,16 @@ processors: timeout: 100ms exporters: - logging: - logLevel: debug # OTLP for Tracetest otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector + endpoint: tracetest-agent:4317 # Send traces to Tracetest. Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector tls: insecure: true # OTLP for New Relic otlp/newrelic: endpoint: otlp.nr-data.net:443 headers: - "api-key": "" # Send traces to New Relic. + api-key: ${NEW_RELIC_INGEST_LICENSE} # Send traces to New Relic. # Read more in docs here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-setup/#collector-export # And here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/collector/opentelemetry-collector-basic/ @@ -237,55 +122,60 @@ service: traces/newrelic: receivers: [otlp] processors: [batch] - exporters: [logging, otlp/newrelic] + exporters: [otlp/newrelic] ``` -**Important!** Take a closer look at the sampling configs in both the `collector.config.yaml` and `tracetest.config.yaml`. They both set sampling to 100%. This is crucial when running trace-based e2e and integration tests. +**Important!** Take a closer look at the sampling configs in both the `collector.config.yaml`. It has set sampling to 100%. This is crucial when running trace-based e2e and integration tests. -## Run both the OpenTelemetry Demo app and Tracetest +## Running the tests -To start both the OpenTelemetry and Tracetest we will run this command: +### The Test File -```bash -docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up # add --build if the images are not built already -``` - -This will start your Tracetest instance on `http://localhost:11633/`. - -Open the URL and [start creating tests in the Web UI](https://docs.tracetest.io/web-ui/creating-tests)! Make sure to use the endpoints within your Docker network like `http://otel-frontend:8084/` when creating tests. - -This is because your OpenTelemetry Demo and Tracetest are in the same network. - -> Note: View the `demo` section in the `tracetest.config.yaml` to see which endpoints from the OpenTelemetry Demo are available for running tests. +Check out the `resources/test.yaml` file. -Here's a sample of a failed test run, which happens if you add this assertion: +```yaml +# resources/test.yaml +type: Test +spec: + id: YJmFC7hVg + name: Otel - List Products + description: Otel - List Products + trigger: + type: http + httpRequest: + url: http://otel-frontend:8084/api/products + method: GET + headers: + - key: Content-Type + value: application/json + specs: + - selector: + span[tracetest.span.type="http" name="API HTTP GET" http.target="/api/products" + http.method="GET"] + assertions: + - attr:http.status_code = 200 + - attr:tracetest.span.duration < 50ms + - selector: span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] + assertions: + - attr:rpc.grpc.status_code = 0 + - selector: + span[tracetest.span.type="rpc" name="hipstershop.ProductCatalogService/ListProducts" + rpc.system="grpc" rpc.method="ListProducts" rpc.service="hipstershop.ProductCatalogService"] + assertions: + - attr:rpc.grpc.status_code = 0 ``` -attr:tracetest.span.duration < 50ms -``` - -![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1672998179/Blogposts/tracetest-lightstep-partnership/screely-1672998159326_depw45.png) - -Increasing the duration to a more reasonable `500ms` will make the test pass. -![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1672998252/Blogposts/tracetest-lightstep-partnership/screely-1672998249450_mngghb.png) - -## Run Tracetest Tests with the Tracetest CLI - -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: +To run the test, run this command in the terminal: ```bash -tracetest configure --server-url http://localhost:11633 +docker compose run tracetest-run ``` -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `http-test.yaml` file. +Check out the `test.yaml` file. ```yaml -# http-test.yaml - +# resurces/test.yaml type: Test spec: id: YJmFC7hVg @@ -321,7 +211,7 @@ This file defines the a test the same way you would through the Web UI. To run the test, run this command in the terminal: ```bash -tracetest run test -f ./http-test.yaml +docker compose run tracetest-run ``` This test will fail just like the sample above due to the `attr:tracetest.span.duration < 50ms` assertion. diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-signoz-pokeshop.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-signoz-pokeshop.mdx index babca441d2..df229355ef 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-signoz-pokeshop.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-signoz-pokeshop.mdx @@ -16,10 +16,6 @@ keywords: image: https://res.cloudinary.com/djwdcmwdz/image/upload/v1698686403/docs/Blog_Thumbnail_14_rsvkmo.jpg --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import CodeBlock from '@theme/CodeBlock'; - :::note [Check out the source code on GitHub here.](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-signoz-pokeshop) ::: @@ -34,19 +30,13 @@ import CodeBlock from '@theme/CodeBlock'; This is a simple quick start guide on how to configure a fully instrumented API to be used with Tracetest for enhancing your E2E and integration tests with trace-based testing. The infrastructure will use SigNoz as the trace data store and the Pokeshop API to generate the telemetry data. -```mdx-code-block - - -``` ## Prerequisites **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,11 +54,9 @@ cd tracetest/examples/tracetest-signoz-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 -f ./docker-compose.agent.yaml up -d`. -5. This example is configured to use the SigNoz Tracing Backend. Ensure the environment you're using to run this example is configured to use the SigNoz Tracing Backend by clicking on Settings, Tracing Backend, SigNoz, 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. 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. @@ -89,8 +77,10 @@ This is a [fragment from the main tracing file](https://github.com/kubeshop/poke Configure the `.env` like shown below. ```bash -TRACETEST_API_KEY="" -TRACETEST_API_TOKEN="" +# Get the required information here: https://app.tracetest.io/retrieve-token + +TRACETEST_TOKEN="" +TRACETEST_ENVIRONMENT_ID="" ``` ## Configuring SigNoz @@ -110,663 +100,19 @@ tracetest config -t tracetest apply datastore -f ./tracetest/tracetest-tracing-backend.yaml ``` -## Run the Pokeshop Demo App, SigNoz, and Tracetest Agent with Docker Compose - -The [`docker-compose.agent.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml) in the root directory contains the Pokeshop Demo app services. - -The [`docker-compose.agent.yaml` file](https://github.com/kubeshop/tracetest/blob/main/examples/tracetest-signoz-pokeshop/docker-compose.agent.yaml) also contains the Tracetest Agent, OpenTelemetry Collector and all SigNoz services. - -To start it, run this command: - -```bash -docker compose -f ./docker-compose.agent.yaml up -d -``` - -This will start the Pokeshop Demo app, SigNoz, OpenTelemetry Collector, and Tracetest Agent. - -## Run Tracetest Tests +### Run Tracetest Tests -1. Open [Tracetest](https://app.tracetest.io/) -2. [Configure SigNoz as a tracing backend](/configuration/connecting-to-data-stores/signoz) 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: +To execute the tests, run this command: ```bash -tracetest configure -t -tracetest run test -f ./tests/test.yaml -``` - -```mdx-code-block - - -``` - -## Prerequisites - -You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine to run this quick start app! - -## Project Structure - -The project is built with Docker Compose. - -### 1. Tracetest - -The `collector.config.yaml` file, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for the configuring Tracetest and it's OpenTelemetry Collector. - -### 2. SigNoz - -The `signoz` directory contains all files required to configure SigNoz. - -### Docker Compose Network - -All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `tracetest/collector.config.yaml` will map to the `tracetest` service, where the port `4317` is the port where Tracetest accepts telemetry data. - -## Pokeshop API - -The Pokeshop API is a fully instrumented REST API that makes use of different services to mimic a real life scenario. - -It is instrumented using the [OpenTelemetry standards for Node.js](https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/), sending the data to the ADOT collector that will be pushing the telemetry information to both the AWS X-Ray service. - -This is a fragment from the main tracing file from the [Pokeshop API repo.](https://github.com/kubeshop/pokeshop) - -```typescript -import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'; -import * as opentelemetry from '@opentelemetry/api'; -import { api, NodeSDK } from '@opentelemetry/sdk-node'; -import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; -import { Resource } from '@opentelemetry/resources'; -import * as dotenv from 'dotenv'; -import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; -import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis'; -import { PgInstrumentation } from '@opentelemetry/instrumentation-pg'; -import { AmqplibInstrumentation } from '@opentelemetry/instrumentation-amqplib'; -import { SpanStatusCode } from '@opentelemetry/api'; -import { B3Propagator } from '@opentelemetry/propagator-b3'; - -dotenv.config(); -api.propagation.setGlobalPropagator(new B3Propagator()); - -const { COLLECTOR_ENDPOINT = '', SERVICE_NAME = 'pokeshop' } = process.env; - -let globalTracer: opentelemetry.Tracer | null = null; - -async function createTracer(): Promise { - const collectorExporter = new OTLPTraceExporter({ - url: COLLECTOR_ENDPOINT, - }); - - const spanProcessor = new BatchSpanProcessor(collectorExporter); - const sdk = new NodeSDK({ - traceExporter: collectorExporter, - // @ts-ignore - instrumentations: [new IORedisInstrumentation(), new PgInstrumentation(), new AmqplibInstrumentation()], - }); - - sdk.configureTracerProvider({}, spanProcessor); - sdk.addResource( - new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: SERVICE_NAME, - }) - ); - - await sdk.start(); - process.on('SIGTERM', () => { - sdk - .shutdown() - .then( - () => console.log('SDK shut down successfully'), - err => console.log('Error shutting down SDK', err) - ) - .finally(() => process.exit(0)); - }); - - const tracer = opentelemetry.trace.getTracer(SERVICE_NAME); - - globalTracer = tracer; - - return globalTracer; -} -``` - -The `docker-compose.yaml` file includes the definitions for all of the required services by the Pokeshop API, which includes: - -- **Postgres** - To save Pokemon information. -- **Redis** - For in memory strage. -- **RabbitMQ** - For async processing use cases. -- **API** - The Pokeshop API main container. -- **Worker** - The Pokeshop worker instance. - -```yaml -version: "3" - -#... - -services: - #... - - # Demo - postgres: - image: postgres:14 - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" - interval: 1s - timeout: 5s - retries: 60 - ports: - - 5432:5432 - - demo-cache: - image: redis:6 - restart: unless-stopped - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 1s - timeout: 3s - retries: 60 - - demo-queue: - image: rabbitmq:3.8-management - restart: unless-stopped - healthcheck: - test: rabbitmq-diagnostics -q check_running - interval: 1s - timeout: 5s - retries: 60 - - demo-api: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: api - ports: - - "8081:8081" - healthcheck: - test: ["CMD", "wget", "--spider", "localhost:8081"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - - demo-worker: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: worker - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - - demo-rpc: - image: kubeshop/demo-pokemon-api:latest - restart: unless-stopped - pull_policy: always - environment: - REDIS_URL: demo-cache - DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public - RABBITMQ_HOST: demo-queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - NPM_RUN_COMMAND: rpc - ports: - - 8082:8082 - healthcheck: - test: ["CMD", "lsof", "-i", "8082"] - interval: 1s - timeout: 3s - retries: 60 - depends_on: - postgres: - condition: service_healthy - demo-cache: - condition: service_healthy - demo-queue: - condition: service_healthy - # Demo End -``` - -## Tracetest - -The `docker-compose.yaml` includes two services related to Tracetest. The Tracetest instance also connects to the `postgres` service. - -- **Postgres** - Postgres is a prerequisite for Tracetest to work. It stores trace data when running the trace-based tests. -- [**OpenTelemetry Collector**)](https://opentelemetry.io/docs/collector/getting-started/) - Vendor-agnostic way to receive, process and export telemetry data. -- [**Tracetest**](https://tracetest.io/) - Trace-based testing that generates end-to-end tests automatically from traces. - -```yaml -version: "3" - -# ... -services: - - # ... - - # Tracetest - tracetest: - image: kubeshop/tracetest:${TAG:-latest} - platform: linux/amd64 - volumes: - - type: bind - source: ./tracetest/tracetest-config.yaml - target: /app/tracetest.yaml - - type: bind - source: ./tracetest/tracetest-provision.yaml - target: /app/provision.yaml - command: --provisioning-file /app/provision.yaml - ports: - - 11633:11633 - extra_hosts: - - "host.docker.internal:host-gateway" - depends_on: - postgres: - condition: service_healthy - otel-collector: - condition: service_started - healthcheck: - test: [ "CMD", "wget", "--spider", "localhost:11633" ] - interval: 1s - timeout: 3s - retries: 60 - environment: - TRACETEST_DEV: ${TRACETEST_DEV} - - otel-collector: - image: otel/opentelemetry-collector:0.54.0 - command: - - "--config" - - "/otel-local-config.yaml" - volumes: - - ./tracetest/collector.config.yaml:/otel-local-config.yaml - ports: - - 4317:4317 - depends_on: - signoz-otel-collector: - condition: service_started - signoz-otel-collector-metrics: - condition: service_started - # Tracetest End +docker compose run tracetest-run ``` -Tracetest depends on Postgres and the OpenTelemetry Collector. Tracetest requires config files to be loaded via a volume. The volumes are mapped from the `tracetest` directory into the `root` directory of the Tracetest container instance and the respective config files. - -The `collector.config.yaml` file contains the OpenTelemetry Collector configuration that enables routing traces from the Pokeshop API to both Tracetest and SigNoz. - -```yaml -# collector.config.yaml - -receivers: - otlp: - protocols: - grpc: - http: - -processors: - batch: - timeout: 100ms - - # Data sources: traces - probabilistic_sampler: - hash_seed: 22 - sampling_percentage: 100 - -exporters: - # OTLP for Tracetest - otlp/tracetest: - endpoint: tracetest:4317 # Send traces to Tracetest. - # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector - tls: - insecure: true - # OTLP for Signoz - otlp/signoz: - endpoint: signoz-otel-collector:4317 - tls: - insecure: true - -service: - pipelines: - traces: - receivers: [otlp] - processors: [probabilistic_sampler, batch] - exporters: [otlp/signoz,otlp/tracetest] -``` - -The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance. It also enables forwarding Tracetest's internal telemetry to SigNoz as well, with the `telemetry` and `server` config. - -```yaml -# tracetest-config.yaml - -postgres: - host: postgres - user: postgres - password: postgres - port: 5432 - dbname: postgres - params: sslmode=disable - -telemetry: - exporters: - collector: - serviceName: tracetest - sampling: 100 # 100% - exporter: - type: collector - collector: - endpoint: otel-collector:4317 - -server: - telemetry: - exporter: collector - applicationExporter: collector - -``` - -The `tracetest-provision.yaml` file defines the trace data store, set to SigNoz, meaning the traces will be forwarded via the OpenTelemetry Collector to both Tracetest when running tests and SigNoz where they are stored. - -```yaml -# tracetest-provision.yaml - ---- -type: PollingProfile -spec: - name: Default - strategy: periodic - default: true - periodic: - retryDelay: 5s - timeout: 10m - ---- -type: DataStore -spec: - name: Signoz - type: signoz - ---- -type: TestRunner -spec: - id: current - name: default - requiredGates: - - analyzer-score - - test-specs - ---- -type: Demo -spec: - type: pokeshop - enabled: true - name: pokeshop - opentelemetryStore: {} - pokeshop: - httpEndpoint: http://demo-api:8081 - grpcEndpoint: demo-rpc:8082 -``` - -How do traces reach SigNoz? - -The Pokeshop API code uses the native Node.js OpenTelemetry modules which send information to the OpenTelemetry Collector to be processed and then sent to the internal SigNoz OpenTelemetry Collector. - -## SigNoz - -The `docker-compose.yaml` includes 7 services related to SigNoz. - -- [**Zookeeper**](https://zookeeper.apache.org/) - ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. -- [**ClickHouse**](https://clickhouse.com/) - ClickHouse is the fastest and most resource efficient open-source database for real-time apps and analytics. -- [**SigNoz - Alert Manager**](https://github.com/SigNoz/alertmanager) - The `Alertmanager` handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver integrations such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts. -- [**SigNoz - Query Service**](https://github.com/SigNoz/signoz/tree/develop/pkg/query-service) - Handles querying for data. -- [**SigNoz - Front end**](https://github.com/SigNoz/signoz/tree/develop/frontend) - The SigNoz front-end app. -- [**SigNoz - OpenTelemetry Collector**)](https://opentelemetry.io/docs/collector/getting-started/) - Vendor-agnostic way to receive, process and export telemetry data. -- [**SigNoz - OpenTelemetry Collector Metrics**)](https://opentelemetry.io/docs/collector/getting-started/) - Vendor-agnostic way to receive, process and export telemetry data. This service is dedicated to metrics. - -```yaml -version: "3" - -# ... -services: - - # ... - - # SigNoz - zookeeper-1: - image: bitnami/zookeeper:3.7.1 - container_name: zookeeper-1 - hostname: zookeeper-1 - user: root - volumes: - - ./signoz/data/zookeeper-1:/bitnami/zookeeper - environment: - - ZOO_SERVER_ID=1 - - ALLOW_ANONYMOUS_LOGIN=yes - - ZOO_AUTOPURGE_INTERVAL=1 - - clickhouse: - restart: on-failure - image: clickhouse/clickhouse-server:22.8.8-alpine - tty: true - depends_on: - - zookeeper-1 - logging: - options: - max-size: 50m - max-file: "3" - healthcheck: - test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"] - interval: 30s - timeout: 5s - retries: 3 - ulimits: - nproc: 65535 - nofile: - soft: 262144 - hard: 262144 - container_name: clickhouse - hostname: clickhouse - volumes: - - ./signoz/clickhouse-config.xml:/etc/clickhouse-server/config.xml - - ./signoz/clickhouse-users.xml:/etc/clickhouse-server/users.xml - - ./signoz/custom-function.xml:/etc/clickhouse-server/custom-function.xml - - ./signoz/clickhouse-cluster.xml:/etc/clickhouse-server/config.d/cluster.xml - - ./signoz/data/clickhouse/:/var/lib/clickhouse/ - - ./signoz/user_scripts:/var/lib/clickhouse/user_scripts/ - - alertmanager: - image: signoz/alertmanager:${ALERTMANAGER_TAG:-0.23.1} - volumes: - - ./signoz/data/alertmanager:/data - depends_on: - query-service: - condition: service_healthy - restart: on-failure - command: - - --queryService.url=http://query-service:8085 - - --storage.path=/data - - query-service: - image: signoz/query-service:${DOCKER_TAG:-0.22.0} - command: ["-config=/root/config/prometheus.yml"] - volumes: - - ./signoz/prometheus.yml:/root/config/prometheus.yml - - ./signoz/data/signoz/:/var/lib/signoz/ - environment: - - ClickHouseUrl=tcp://clickhouse:9000/?database=signoz_traces - - ALERTMANAGER_API_PREFIX=http://alertmanager:9093/api/ - - SIGNOZ_LOCAL_DB_PATH=/var/lib/signoz/signoz.db - - DASHBOARDS_PATH=/root/config/dashboards - - STORAGE=clickhouse - - GODEBUG=netdns=go - - TELEMETRY_ENABLED=true - - DEPLOYMENT_TYPE=docker-standalone-amd - restart: on-failure - healthcheck: - test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"] - interval: 30s - timeout: 5s - retries: 3 - depends_on: - clickhouse: - condition: service_healthy - - frontend: - image: signoz/frontend:${DOCKER_TAG:-0.22.0} - restart: on-failure - depends_on: - - alertmanager - - query-service - ports: - - 3301:3301 - volumes: - - ./signoz/common/nginx-config.conf:/etc/nginx/conf.d/default.conf - - signoz-otel-collector: - image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.2} - command: ["--config=/etc/otel-collector-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] - user: root # required for reading docker container logs - volumes: - - ./signoz/otel-collector-config.yaml:/etc/otel-collector-config.yaml - - /var/lib/docker/containers:/var/lib/docker/containers:ro - environment: - - OTEL_RESOURCE_ATTRIBUTES=host.name=signoz-host,os.type=linux - - DOCKER_MULTI_NODE_CLUSTER=false - - LOW_CARDINAL_EXCEPTION_GROUPING=false - restart: on-failure - depends_on: - clickhouse: - condition: service_healthy - - signoz-otel-collector-metrics: - image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.2} - command: ["--config=/etc/otel-collector-metrics-config.yaml", "--feature-gates=-pkg.translator.prometheus.NormalizeName"] - volumes: - - ./signoz/otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml - restart: on-failure - depends_on: - clickhouse: - condition: service_healthy - # SigNoz End -``` - -SigNoz depends on ClickHouse and Zookeeper. The SigNoz services require config files to be loaded via volumes. The volumes are mapped from the `signoz` directory. - -## Run the Pokeshop API, SigNoz and Tracetest - -To start all the services, run this command: - -```bash -docker-compose up -``` - -This will start your Tracetest instance on `http://localhost:11633/`. Open it and start creating tests! - -Make sure to use the `http://demo-api:8081/` URL in your test creation, because your Pokeshop API and Tracetest are in the same network. - -## Run Tracetest Tests with the Tracetest CLI - -First, [install the CLI](https://docs.tracetest.io/getting-started/installation#install-the-tracetest-cli). -Then, configure the CLI: - -```bash -tracetest configure --server-url http://localhost:11633 -``` - -Once configured, you can run a test against the Tracetest instance via the terminal. - -Check out the `tests/test.yaml` file. - -```yaml -# tests/test.yaml - -type: Test -spec: - id: ZVJwkpC4g - name: Pokeshop - Import - description: Import a Pokemon - trigger: - type: http - httpRequest: - method: POST - url: http://demo-api:8081/pokemon/import - body: '{"id":6}' - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http"] - name: "All HTTP Spans: Status code is 200" - assertions: - - attr:http.status_code = 200 - - selector: span[tracetest.span.type="general" name="import pokemon"] - name: Validate that this span always exists after the message queue - assertions: - - attr:tracetest.selected_spans.count = 1 - - attr:span.events not-contains "exception" - - selector: span[tracetest.span.type="database" name="get pokemon_6" db.system="redis" db.operation="get" db.redis.database_index="0"] - name: Validate that Redis is using Charizard. - assertions: - - attr:db.payload = '{"key":"pokemon_6"}' - - selector: span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres" db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"] - name: Validate that the Postgres has Charizard. - assertions: - - attr:db.result contains "charizard" -``` - -This file defines a test the same way you would through the Web UI. - -To run the test, run this command in the terminal: - -```bash -tracetest run test -f ./tests/test.yaml -``` - -```bash title="Output:" -✔ Pokeshop - Import (http://localhost:11633/test/ZVJwkpC4g/run/1/test) - trace id: 4eff1e124f67cf7a802b3c4fc51c19d4 - ✔ All HTTP Spans: Status code is 200 - ✔ Validate that this span always exists after the message queue - ✔ Validate that Redis is using Charizard. - ✔ Validate that the Postgres has Charizard. -``` - -![tracetest web ui overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1692356467/Blogposts/Docs/screely-1692356427154_ewzduy.png) - -## View Trace Spans Over Time in SigNoz - -To access a historical overview of all the trace spans the Pokeshop App generates, jump over to SigNoz. - -![signoz trace overview](https://res.cloudinary.com/djwdcmwdz/image/upload/v1692364823/Blogposts/Docs/screely-1692364815231_birvhj.png) - -You can also drill down into a particular trace. - -![signoz trace drilldown](https://res.cloudinary.com/djwdcmwdz/image/upload/v1692364964/Blogposts/Docs/screely-1692364957669_te7pe2.png) - -With SigNoz and Tracetest, you get the best of both worlds. You can run trace-based tests and automate running E2E and integration tests against real trace data. And, use SigNoz to get a historical overview of all traces your distributed application generates. - -```mdx-code-block - - -``` +This will: +1. Start the Node.js app, the OpenTelemetry Collector, and send the traces to Signoz. +2. Start the Tracetest Agent. +3. Configure the tracing backend and create tests in your environment. +4. Run the tests. ## Learn More From 000e131c75cbb5a713b6bf0eaa161352052231ac Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Thu, 15 Aug 2024 11:15:45 -0600 Subject: [PATCH 12/12] PR comments update --- .../recipes/running-tracetest-with-datadog.mdx | 6 +++--- .../recipes/running-tracetest-with-dynatrace.mdx | 10 +++++----- .../recipes/running-tracetest-with-lightstep.mdx | 6 +++--- .../recipes/running-tracetest-with-new-relic.mdx | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx index 56a304b647..00e69865be 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-datadog.mdx @@ -52,7 +52,7 @@ Follow these instructions to run the quick start: 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. +Follow the sections below for a detailed breakdown of what the example you just ran did and how it works. ## Project Structure @@ -64,7 +64,7 @@ The `docker-compose.yaml` file and `.env` file in the root directory are for the ### Docker Compose Network -All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where port `4317` is the port where Tracetest accepts traces. +All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest-agent:4317` in the `collector.config.yaml` will map to the `tracetest-agent` service, where port `4317` is the port where Tracetest Agent accepts traces. ## OpenTelemetry Demo @@ -162,7 +162,7 @@ service: exporters: [datadog] ``` -## Running the tests +## Running the Tests ### The Test File diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx index 0a4ae0b10c..f2d05d7379 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.mdx @@ -52,7 +52,7 @@ Follow these instructions to run the quick start: 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. +Follow the sections below for a detailed breakdown of what the example you just ran did and how it works. ## Project Structure @@ -68,7 +68,7 @@ The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.ya ### Docker Compose Network -All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where port `4317` is the port where Tracetest accepts traces. +All `services` in the `docker-compose.yaml` are on the same network, defined by the `networks` section on each file, and will be reachable by hostname from within other services. E.g. `tracetest-agent:4317` in the `collector.config.yaml` will map to the `tracetest-agent` service, where port `4317` is the port where Tracetest Agent accepts traces. ## OpenTelemetry Demo @@ -90,7 +90,7 @@ Let's fix this by configuring Tracetest and the OpenTelemetry Collector to forwa ### Sending Traces to Tracetest and Dynatrace -The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Dynatrace in another. +The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest Agent's OTLP endpoint `tracetest-agent:4317` in one pipeline, and to Dynatrace in another. Make sure to add your Dynatrace API Key to the `otlp` exporter (needs the `openTelemetryTrace.ingest` permission). @@ -130,7 +130,7 @@ receivers: - targets: ['0.0.0.0:8888'] processors: - batch: # this configuration is needed to guarantee that the data is sent correctly to Datadog + batch: # this configuration is needed to guarantee that the data is sent correctly to Dynatrace send_batch_max_size: 100 send_batch_size: 10 timeout: 10s @@ -163,7 +163,7 @@ service: exporters: [otlphttp/dynatrace] ``` -## Running the tests +## Running the Tests ### The Test File diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx index 186165d554..eea18d3587 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-lightstep.mdx @@ -52,7 +52,7 @@ Follow these instructions to run the quick start: 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. +Follow the sections below for a detailed breakdown of what the example you just ran did and how it works. ## Project Structure @@ -87,7 +87,7 @@ Let's fix this by configuring Tracetest and OpenTelemetry Collector to forward t **How to Send Traces to Tracetest and Lightstep** -The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest's OTLP endpoint `tracetest:4317` in one pipeline, and to Lightstep in another. +The `collector.config.yaml` explains that. It receives traces via either `grpc` or `http`. Then, exports them to Tracetest Agent's OTLP endpoint `tracetest-agent:4317` in one pipeline, and to Lightstep in another. Make sure to add your Lightstep access token in the headers of the `otlp/lightstep` exporter. @@ -126,7 +126,7 @@ service: exporters: [otlp/lightstep] ``` -## Running the tests +## Running the Tests ### The Test File diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx b/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx index 8089fc0956..3933183635 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-new-relic.mdx @@ -52,7 +52,7 @@ Follow these instructions to run the quick start: 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. +Follow the sections below for a detailed breakdown of what the example you just ran did and how it works. ## Project Structure @@ -64,7 +64,7 @@ The `docker-compose.yaml` file and `.env` file in the root directory are for the ### Docker Compose Network -All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:4317` in the `collector.config.yaml` will map to the `tracetest` service, where the port `4317` is the port where Tracetest accepts traces. +All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest-agent:4317` in the `collector.config.yaml` will map to the `tracetest-agent` service, where the port `4317` is the port where Tracetest Agent accepts traces. ## OpenTelemetry Demo @@ -127,7 +127,7 @@ service: **Important!** Take a closer look at the sampling configs in both the `collector.config.yaml`. It has set sampling to 100%. This is crucial when running trace-based e2e and integration tests. -## Running the tests +## Running the Tests ### The Test File