From 0b4e213a0ec2d69ab6cf39eea4a20ce7dde701fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adnan=20Rahi=C4=87?= Date: Wed, 25 Oct 2023 15:20:36 +0200 Subject: [PATCH] examples(grafana): update pokeshop grafana sample (#3287) --- .../README.md | 4 ++-- .../docker-compose.yml | 5 ++-- .../tests/test.yaml | 23 ++++++++----------- .../tracetest.config.yaml | 15 ++++++++++++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/examples/tracetest-grafana-tempo-pokeshop/README.md b/examples/tracetest-grafana-tempo-pokeshop/README.md index 882a8b2a6f..45dfe7f442 100644 --- a/examples/tracetest-grafana-tempo-pokeshop/README.md +++ b/examples/tracetest-grafana-tempo-pokeshop/README.md @@ -15,6 +15,6 @@ This examples' objective is to show how you can: 4. Test if it works by running: `tracetest run test -f tests/test.yaml`. This would trigger a test that will send and retrieve spans from the Grafana Tempo instance that is running on your machine. View the test on `http://localhost:11633`. 5. View traces in Grafana on `http://localhost:3000`. Use this TraceQL query: - ```yaml - { name="POST /pokemon/import" } + ```text + { name="Tracetest trigger" } || { name="POST /pokemon/import?" } || { name="POST /pokemon/import" } ``` diff --git a/examples/tracetest-grafana-tempo-pokeshop/docker-compose.yml b/examples/tracetest-grafana-tempo-pokeshop/docker-compose.yml index 3863a2a5d7..71b74a5e9a 100644 --- a/examples/tracetest-grafana-tempo-pokeshop/docker-compose.yml +++ b/examples/tracetest-grafana-tempo-pokeshop/docker-compose.yml @@ -3,7 +3,7 @@ services: # Tracetest tracetest: - image: kubeshop/tracetest:v0.12.2 + image: kubeshop/tracetest:v0.14.3 volumes: - ./tracetest.config.yaml:/app/tracetest.yaml - ./tracetest.provision.yaml:/app/provisioning.yaml @@ -38,7 +38,8 @@ services: - ./tempo.config.yaml:/etc/tempo.yaml - ./tempo-data:/tmp/tempo ports: - - "3200" # tempo + - "3200:3200" # tempo http + - "9095:9095" # tempo grpc - "4317" # otlp grpc - "4318" # otlp http grafana: diff --git a/examples/tracetest-grafana-tempo-pokeshop/tests/test.yaml b/examples/tracetest-grafana-tempo-pokeshop/tests/test.yaml index aea25e1f3a..45424e2412 100644 --- a/examples/tracetest-grafana-tempo-pokeshop/tests/test.yaml +++ b/examples/tracetest-grafana-tempo-pokeshop/tests/test.yaml @@ -1,6 +1,6 @@ type: Test spec: - id: ZVJwkpC4g + id: MnZ_kD7Ig name: Pokeshop - Import description: Import a Pokemon trigger: @@ -8,25 +8,20 @@ spec: httpRequest: method: POST url: http://demo-api:8081/pokemon/import - body: '{"id":6}' + body: "{\"id\":837483}" headers: - key: Content-Type value: application/json specs: + - selector: span[tracetest.span.type="http" name="GET" http.method="GET"] + name: Validate that the external API does not contain an exception. + assertions: + - attr:span.events not-contains "exception" - 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. + - selector: span[tracetest.span.type="database"] + name: "All Database Spans: Processing time is less than 100ms" assertions: - - attr:db.result contains "charizard" + - attr:tracetest.span.duration < 100ms diff --git a/examples/tracetest-grafana-tempo-pokeshop/tracetest.config.yaml b/examples/tracetest-grafana-tempo-pokeshop/tracetest.config.yaml index fe32b236be..f3116d864f 100644 --- a/examples/tracetest-grafana-tempo-pokeshop/tracetest.config.yaml +++ b/examples/tracetest-grafana-tempo-pokeshop/tracetest.config.yaml @@ -6,3 +6,18 @@ 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