Skip to content

Commit

Permalink
examples-recipes(dynatrace): Fix issues with example app and update d…
Browse files Browse the repository at this point in the history
…ocs (#3060)

* examples-recipes(dynatrace): fix 1

* examples-recipes(dynatrace): typos
  • Loading branch information
adnanrahic committed Aug 14, 2023
1 parent c8843fe commit 4c5741d
Show file tree
Hide file tree
Showing 11 changed files with 747 additions and 87 deletions.
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand 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:
Expand Down Expand Up @@ -113,15 +112,14 @@ 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:
- "--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.
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -207,26 +214,53 @@ 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

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:
Expand All @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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!
Expand Down
85 changes: 85 additions & 0 deletions 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}
Empty file.
2 changes: 1 addition & 1 deletion examples/tracetest-dynatrace/README.md
Expand Up @@ -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
```
```

0 comments on commit 4c5741d

Please sign in to comment.