Skip to content

Commit

Permalink
updating datadog example
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Aug 14, 2024
1 parent 4002218 commit f21a04f
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 203 deletions.
85 changes: 0 additions & 85 deletions examples/tracetest-datadog/.env

This file was deleted.

54 changes: 54 additions & 0 deletions examples/tracetest-datadog/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Get the required information here: https://app.tracetest.io/retrieve-token

TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>"

DATADOG_API_KEY="<YOUR_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
1 change: 1 addition & 0 deletions examples/tracetest-datadog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
11 changes: 11 additions & 0 deletions examples/tracetest-datadog/Dockerfile.tracetest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine

WORKDIR /app
ARG TRACETEST_IMAGE_VERSION=v1.4.0

RUN apk --update add bash jq curl
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION

WORKDIR /resources

ENTRYPOINT ["echo", "Tracetest CLI installed"]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
74 changes: 68 additions & 6 deletions examples/tracetest-datadog/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
# ******************
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions examples/tracetest-datadog/resources/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID

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

echo "Applying Resources"
tracetest apply datastore -f /resources/datastore.yaml
tracetest apply test -f /resources/test.yaml
}

apply
5 changes: 5 additions & 0 deletions examples/tracetest-datadog/resources/datastore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: DataStore
spec:
id: current
name: datadog
type: datadog
16 changes: 16 additions & 0 deletions examples/tracetest-datadog/resources/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID

run() {
echo "Configuring Tracetest"
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID

echo "Running Trace-Based Tests..."
tracetest run test -f /resources/test.yaml
}

run
File renamed without changes.
Loading

0 comments on commit f21a04f

Please sign in to comment.