diff --git a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.md b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.md index 10e9c9215c..c0f67d6c2e 100644 --- a/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.md +++ b/docs/docs/examples-tutorials/recipes/running-tracetest-with-dynatrace.md @@ -6,7 +6,7 @@ [Tracetest](https://tracetest.io/) is a testing tool based on [OpenTelemetry](https://opentelemetry.io/) that allows you to test your distributed application. It allows you to use data from distributed traces generated by OpenTelemetry to validate and assert if your application has the desired behavior defined by your test definitions. -[Dynatrace](https://www.dynatrace.com/) TODO. +[Dynatrace](https://www.dynatrace.com/) is a unified Observability and security platform that allows you to monitor and secure your full stack on one AI-powered data platform. From infrastructure and application observability to realtime security analytics and protection, digital experience monitoring and business analytics. All underpinned by a composable app-based platform with a custom Observability-driven workflow engine. ## OpenTelemetry Demo `v1.3.0` with Dynatrace, OpenTelemetry and Tracetest @@ -28,22 +28,21 @@ 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 Lightstep. +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. - ## 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. +The [OpenTelemetry 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. Read more about the OpenTelemetry Demo [here](https://opentelemetry.io/blog/2022/announcing-opentelemetry-demo-release/). -The `docker-compose.yaml` contains 14 services. +The `docker-compose.yaml` contains 14 services for the demo and 3 supporting dependent services. -To start the OpenTelemetry Demo by itself, run this command: +To start the OpenTelemetry Demo **by itself**, run this command: ```bash docker compose up @@ -81,10 +80,10 @@ services: - "host.docker.internal:host-gateway" volumes: - type: bind - source: ./tracetest-config.yaml + source: ./tracetest/tracetest-config.yaml target: /app/tracetest.yaml - type: bind - source: ./tracetest-provision.yaml + source: ./tracetest/tracetest-provision.yaml target: /app/provisioning.yaml command: --provisioning-file /app/provisioning.yaml healthcheck: @@ -113,7 +112,7 @@ services: retries: 60 otel-collector: - image: otel/opentelemetry-collector-contrib:0.68.0 + image: otel/opentelemetry-collector-contrib:0.82.0 container_name: otel-collector restart: unless-stopped command: @@ -121,7 +120,6 @@ services: - "/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. @@ -139,7 +137,7 @@ The `tracetest-config.yaml` file contains the basic setup of connecting Tracetes --- postgres: - host: postgres + host: tt-postgres user: postgres password: postgres port: 5432 @@ -185,17 +183,26 @@ spec: default: true periodic: retryDelay: 5s - timeout: 180s + timeout: 10m --- type: DataStore spec: - name: dynatrace + name: Dynatrace type: dynatrace +--- +type: TestRunner +spec: + id: current + name: default + requiredGates: + - analyzer-score + - test-specs + ``` -**Sending Traces to Tracetest and Dynatrace** +### 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. @@ -207,9 +214,37 @@ receivers: protocols: http: grpc: + 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 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 @@ -217,16 +252,15 @@ 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: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 Dynatrace - otlp/dynatrace: - endpoint: https://abc123.live.dynatrace.com/api/v2/otlp # Send traces to Dynatrace. Read more in docs here: https://www.dynatrace.com/support/help/extend-dynatrace/opentelemetry/collector#configuration + 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 dt0c01.sample.secret" # Requires "openTelemetryTrace.ingest" permission service: pipelines: @@ -237,7 +271,11 @@ service: traces/dynatrace: receivers: [otlp] processors: [batch] - exporters: [otlp/dynatrace] + exporters: [otlphttp/dynatrace] + metrics: + receivers: [hostmetrics, otlp] + processors: [batch] + exporters: [otlphttp/dynatrace] ``` ## Run Both the OpenTelemetry Demo App and Tracetest @@ -248,7 +286,11 @@ To start both OpenTelemetry and Tracetest, run this command: docker-compose -f docker-compose.yaml -f tracetest/docker-compose.yaml up ``` -This will start your Tracetest instance on `http://localhost:11633/`. +:::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. @@ -322,17 +364,21 @@ tracetest run test -f ./http-test.yaml This test will fail just like the sample above due to the `attr:tracetest.span.duration < 10ms` 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) +✘ OpenTelemetry Shop - List Products (http://localhost:11633/test/JBYAfKJ4R/run/1/test) - trace id: b9db3e805490f6e1d9aff7c48100d367 + ✘ span[tracetest.span.type="general" name="Tracetest trigger"] + ✘ #bf9abd7861371975 + ✔ attr:tracetest.response.status = 200 (200) + ✘ attr:tracetest.span.duration < 10ms (1.3s) (http://localhost:11633/test/JBYAfKJ4R/run/1/test?selectedAssertion=0&selectedSpan=bf9abd7861371975) + ✔ span[tracetest.span.type="rpc" name="grpc.hipstershop.ProductCatalogService/ListProducts"] + ✔ #52a4bd4cbace9c4b + ✔ 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"] + ✔ #533d2199d7e26437 + ✔ attr:rpc.grpc.status_code = 0 (0) + + ✘ Required gates + ✔ analyzer-score + ✘ test-specs ``` If you edit the duration as in the Web UI example above, the test will pass! diff --git a/examples/tracetest-dynatrace/.env b/examples/tracetest-dynatrace/.env new file mode 100644 index 0000000000..3fd31c808e --- /dev/null +++ b/examples/tracetest-dynatrace/.env @@ -0,0 +1,85 @@ +# 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-dynatrace/.gitignore b/examples/tracetest-dynatrace/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/tracetest-dynatrace/README.md b/examples/tracetest-dynatrace/README.md index 4f14533660..a48c8e187a 100644 --- a/examples/tracetest-dynatrace/README.md +++ b/examples/tracetest-dynatrace/README.md @@ -12,4 +12,4 @@ You can run it locally using the command: ```sh docker compose -f ./docker-compose.yaml -f ./tracetest/docker-compose.yaml up -``` \ No newline at end of file +``` diff --git a/examples/tracetest-dynatrace/docker-compose.yaml b/examples/tracetest-dynatrace/docker-compose.yaml new file mode 100644 index 0000000000..f0961154e2 --- /dev/null +++ b/examples/tracetest-dynatrace/docker-compose.yaml @@ -0,0 +1,467 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file was adapted to not build the images, ignore Load Generator and Envoy services and +# to disable the metrics and rely on OTel collector container +# defined on ./tracetest/docker-compose.yaml + +version: '3.9' +x-default-logging: &logging + driver: "json-file" + options: + max-size: "5m" + max-file: "2" + +networks: + default: + name: opentelemetry-demo + driver: bridge + +services: + # ****************** + # Core Demo Services + # ****************** + # Accounting service + accountingservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-accountingservice + platform: linux/amd64 + container_name: accounting-service + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + environment: + - KAFKA_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=accountingservice + depends_on: + otel-collector: + condition: service_started + kafka: + condition: service_healthy + logging: *logging + + # AdService + adservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-adservice + platform: linux/amd64 + container_name: ad-service + deploy: + resources: + limits: + memory: 300M + restart: unless-stopped + ports: + - "${AD_SERVICE_PORT}" + environment: + - AD_SERVICE_PORT + - FEATURE_FLAG_GRPC_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=adservice + depends_on: + - otel-collector + logging: *logging + + # Cart service + cartservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-cartservice + platform: linux/amd64 + container_name: cart-service + deploy: + resources: + limits: + memory: 160M + restart: unless-stopped + ports: + - "${CART_SERVICE_PORT}" + environment: + - CART_SERVICE_PORT + - REDIS_ADDR + - OTEL_EXPORTER_OTLP_ENDPOINT + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=cartservice + - ASPNETCORE_URLS=http://*:${CART_SERVICE_PORT} + depends_on: + - redis-cart + - otel-collector + logging: *logging + + # Checkout service + checkoutservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-checkoutservice + platform: linux/amd64 + container_name: checkout-service + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + ports: + - "${CHECKOUT_SERVICE_PORT}" + environment: + - CHECKOUT_SERVICE_PORT + - CART_SERVICE_ADDR + - CURRENCY_SERVICE_ADDR + - EMAIL_SERVICE_ADDR + - PAYMENT_SERVICE_ADDR + - PRODUCT_CATALOG_SERVICE_ADDR + - SHIPPING_SERVICE_ADDR + - KAFKA_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=checkoutservice + depends_on: + cartservice: + condition: service_started + currencyservice: + condition: service_started + emailservice: + condition: service_started + paymentservice: + condition: service_started + productcatalogservice: + condition: service_started + shippingservice: + condition: service_started + otel-collector: + condition: service_started + kafka: + condition: service_healthy + logging: *logging + + # Currency service + currencyservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-currencyservice + platform: linux/amd64 + container_name: currency-service + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + ports: + - "${CURRENCY_SERVICE_PORT}" + 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 + depends_on: + - otel-collector + logging: *logging + + # Email service + emailservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-emailservice + platform: linux/amd64 + container_name: email-service + deploy: + resources: + limits: + memory: 100M + restart: unless-stopped + ports: + - "${EMAIL_SERVICE_PORT}" + environment: + - APP_ENV=production + - EMAIL_SERVICE_PORT + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:4318/v1/traces + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=emailservice + depends_on: + - otel-collector + logging: *logging + + # Feature Flag service + featureflagservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-featureflagservice + platform: linux/amd64 + container_name: feature-flag-service + deploy: + resources: + limits: + memory: 200M + restart: unless-stopped + ports: + - "${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 + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc + - OTEL_SERVICE_NAME=featureflagservice + - 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}"] + depends_on: + ffs_postgres: + condition: service_healthy + logging: *logging + + # Fraud Detection service + frauddetectionservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-frauddetectionservice + platform: linux/amd64 + container_name: frauddetection-service + deploy: + resources: + limits: + memory: 200M + restart: unless-stopped + environment: + - KAFKA_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=frauddetectionservice + depends_on: + otel-collector: + condition: service_started + kafka: + condition: service_healthy + logging: *logging + + # Frontend + frontend: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-frontend + platform: linux/amd64 + container_name: frontend + restart: unless-stopped + ports: + - "${FRONTEND_PORT}" + environment: + - PORT=${FRONTEND_PORT} + - FRONTEND_ADDR + - AD_SERVICE_ADDR + - CART_SERVICE_ADDR + - CHECKOUT_SERVICE_ADDR + - CURRENCY_SERVICE_ADDR + - PRODUCT_CATALOG_SERVICE_ADDR + - RECOMMENDATION_SERVICE_ADDR + - SHIPPING_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES} + - OTEL_EXPORTER_OTLP_ENDPOINT + - ENV_PLATFORM + - OTEL_SERVICE_NAME=frontend + - PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - WEB_OTEL_SERVICE_NAME=frontend-web + depends_on: + - adservice + - cartservice + - checkoutservice + - currencyservice + - otel-collector + - productcatalogservice + - quoteservice + - recommendationservice + - shippingservice + logging: *logging + + # Payment service + paymentservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice + platform: linux/amd64 + container_name: payment-service + deploy: + resources: + limits: + memory: 200M + restart: unless-stopped + ports: + - "${PAYMENT_SERVICE_PORT}" + environment: + - PAYMENT_SERVICE_PORT + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=paymentservice + depends_on: + - otel-collector + logging: *logging + + # Product Catalog service + productcatalogservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-productcatalogservice + platform: linux/amd64 + container_name: product-catalog-service + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + ports: + - "${PRODUCT_CATALOG_SERVICE_PORT}" + environment: + - PRODUCT_CATALOG_SERVICE_PORT + - FEATURE_FLAG_GRPC_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=productcatalogservice + depends_on: + - otel-collector + logging: *logging + + # Quote service + quoteservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-quoteservice + platform: linux/amd64 + container_name: quote-service + deploy: + resources: + limits: + memory: 30M + restart: unless-stopped + ports: + - "${QUOTE_SERVICE_PORT}" + environment: + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:4318/v1/traces + - OTEL_PHP_AUTOLOAD_ENABLED=true + - QUOTE_SERVICE_PORT + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=quoteservice + depends_on: + - otel-collector + logging: *logging + + # Recommendation service + recommendationservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-recommendationservice + platform: linux/amd64 + container_name: recommendation-service + deploy: + resources: + limits: + memory: 500M # This is high to enable supporting the recommendationCache feature flag use case + restart: unless-stopped + ports: + - "${RECOMMENDATION_SERVICE_PORT}" + environment: + - RECOMMENDATION_SERVICE_PORT + - PRODUCT_CATALOG_SERVICE_ADDR + - FEATURE_FLAG_GRPC_SERVICE_ADDR + - OTEL_PYTHON_LOG_CORRELATION=true + - OTEL_TRACES_EXPORTER=otlp + - OTEL_METRICS_EXPORTER=otlp + - OTEL_EXPORTER_OTLP_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=recommendationservice + - PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python + depends_on: + - productcatalogservice + - otel-collector + - featureflagservice + logging: *logging + + # Shipping service + shippingservice: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-shippingservice + platform: linux/amd64 + container_name: shipping-service + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + ports: + - "${SHIPPING_SERVICE_PORT}" + environment: + - SHIPPING_SERVICE_PORT + - QUOTE_SERVICE_ADDR + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=shippingservice + depends_on: + - otel-collector + logging: *logging + + # ****************** + # Dependent Services + # ****************** + # Postgres used by Feature Flag service + ffs_postgres: + image: postgres:14 + container_name: postgres + user: postgres + deploy: + resources: + limits: + memory: 200M + restart: unless-stopped + environment: + - POSTGRES_USER=ffs + - POSTGRES_DB=ffs + - POSTGRES_PASSWORD=ffs + logging: *logging + healthcheck: + test: ["CMD-SHELL", "pg_isready -d ffs -U ffs"] + interval: 10s + timeout: 5s + retries: 5 + + # Kafka used by Checkout, Accounting, and Fraud Detection services + kafka: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-kafka + platform: linux/amd64 + container_name: kafka + deploy: + resources: + limits: + memory: 800M + restart: unless-stopped + environment: + - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 + - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=kafka + logging: *logging + healthcheck: + test: nc -z kafka 9092 + start_period: 10s + interval: 5s + timeout: 10s + retries: 10000 + + # Redis used by Cart service + redis-cart: + image: redis:alpine + container_name: redis-cart + user: redis + deploy: + resources: + limits: + memory: 20M + restart: unless-stopped + ports: + - "${REDIS_PORT}" + logging: *logging diff --git a/examples/tracetest-dynatrace/http-test.yaml b/examples/tracetest-dynatrace/http-test.yaml new file mode 100644 index 0000000000..2cf6aacf24 --- /dev/null +++ b/examples/tracetest-dynatrace/http-test.yaml @@ -0,0 +1,26 @@ +type: Test +spec: + id: JBYAfKJ4R + name: OpenTelemetry Shop - List Products + description: List Products available on OTel shop + trigger: + type: http + httpRequest: + url: http://frontend:8084/api/products + method: GET + headers: + - key: Content-Type + value: application/json + specs: + - selector: span[tracetest.span.type="general" name="Tracetest trigger"] + assertions: + - attr:tracetest.response.status = 200 + - attr:tracetest.span.duration < 10ms + - 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-dynatrace/tests/list-tests.yaml b/examples/tracetest-dynatrace/tests/list-tests.yaml deleted file mode 100644 index 294b8af9fe..0000000000 --- a/examples/tracetest-dynatrace/tests/list-tests.yaml +++ /dev/null @@ -1,21 +0,0 @@ -type: Test -spec: - id: e9c6cff9-974d-4263-8a23-22f1e9f975aa - name: List all tracetest tests - description: List all existing tests from tracetest API - trigger: - type: http - httpRequest: - url: http://localhost:11633/api/tests - method: GET - headers: - - key: Content-Type - value: application/json - grpc: - protobufFile: "" - address: "" - method: "" - specs: - - selector: span[tracetest.span.type="http" name="GET /api/tests"] - assertions: - - attr:tracetest.selected_spans.count = 1 diff --git a/examples/tracetest-dynatrace/tracetest/collector.config.yaml b/examples/tracetest-dynatrace/tracetest/collector.config.yaml index 5815a4564e..d41e40b9cd 100644 --- a/examples/tracetest-dynatrace/tracetest/collector.config.yaml +++ b/examples/tracetest-dynatrace/tracetest/collector.config.yaml @@ -1,23 +1,48 @@ receivers: otlp: protocols: - grpc: http: + grpc: + 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: - timeout: 100ms - - # Data sources: traces - probabilistic_sampler: - hash_seed: 22 - sampling_percentage: 100 + 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 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 + # Read more in docs here: https://docs.tracetest.io/configuration/connecting-to-data-stores/opentelemetry-collector tls: insecure: true # OTLP for Dynatrace @@ -28,7 +53,15 @@ exporters: service: pipelines: - traces: + traces/tracetest: + receivers: [otlp] + processors: [batch] + exporters: [otlp/tracetest] + traces/dynatrace: receivers: [otlp] - processors: [probabilistic_sampler, batch] - exporters: [otlphttp/dynatrace, otlp/tracetest] + processors: [batch] + exporters: [otlphttp/dynatrace] + metrics: + receivers: [hostmetrics, otlp] + processors: [batch] + exporters: [otlphttp/dynatrace] diff --git a/examples/tracetest-dynatrace/docker-compose.yml b/examples/tracetest-dynatrace/tracetest/docker-compose.yaml similarity index 67% rename from examples/tracetest-dynatrace/docker-compose.yml rename to examples/tracetest-dynatrace/tracetest/docker-compose.yaml index 37b6a37754..45bfc78e09 100644 --- a/examples/tracetest-dynatrace/docker-compose.yml +++ b/examples/tracetest-dynatrace/tracetest/docker-compose.yaml @@ -1,35 +1,44 @@ -version: '3' +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/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 + target: /app/provisioning.yaml + command: --provisioning-file /app/provisioning.yaml healthcheck: - test: [ "CMD", "wget", "--spider", "localhost:11633" ] + 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} - postgres: + tt-postgres: image: postgres:14 + container_name: tt-postgres environment: POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres @@ -40,11 +49,11 @@ services: retries: 60 otel-collector: - image: otel/opentelemetry-collector:0.54.0 + 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 - ports: - - 4317:4317 \ No newline at end of file diff --git a/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml b/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml index cbe3226feb..3edb085fe2 100644 --- a/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml +++ b/examples/tracetest-dynatrace/tracetest/tracetest-config.yaml @@ -1,5 +1,6 @@ +--- postgres: - host: postgres + host: tt-postgres user: postgres password: postgres port: 5432 @@ -10,7 +11,7 @@ telemetry: exporters: collector: serviceName: tracetest - sampling: 100 # 100% + sampling: 100 exporter: type: collector collector: @@ -19,3 +20,4 @@ telemetry: server: telemetry: exporter: collector + applicationExporter: collector diff --git a/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml b/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml index 95b99d5821..a8c140c85a 100644 --- a/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml +++ b/examples/tracetest-dynatrace/tracetest/tracetest-provision.yaml @@ -1,3 +1,15 @@ +--- +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: @@ -13,6 +25,7 @@ type: DataStore spec: name: Dynatrace type: dynatrace + --- type: TestRunner spec: