Skip to content

Commit

Permalink
chore(examples/docs): Update App Insights
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Aug 16, 2024
1 parent fd0d364 commit 35776f9
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ processors:
exporters:
azuremonitor:
instrumentation_key: ${INSTRUMENTATION_KEY}
otlp/tracetest:
endpoint: tracetest:4317
tls:
insecure: true
otlp/tracetest-agent:
endpoint: tracetest-agent:4317
tls:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 8 additions & 6 deletions examples/tracetest-azure-app-insights/.env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Azure
CONNECTION_STRING=""
RESOURCE_ARM_ID="/subscriptions/<id>/resourceGroups/app-insights-1/providers/microsoft.insights/components/<name>"
# Get the required information here: https://app.tracetest.io/retrieve-token

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

# Tracetest API key and token
TRACETEST_API_KEY="<YOUR_TRACETEST_API_KEY>"
TRACETEST_API_TOKEN="<YOUR_TRACETEST_TOKEN>"
# Azure
APP_INSIGHTS_ACCESS_TOKEN=""
APP_INSIGHTS_ARM_ID="/subscriptions/<id>/resourceGroups/app-insights-1/providers/microsoft.insights/components/<name>"
APP_INSIGHTS_INSTRUMENTATION_STRING=""
1 change: 1 addition & 0 deletions examples/tracetest-azure-app-insights/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
config.yaml
node_modules
.env
resources/datastore.yaml
11 changes: 11 additions & 0 deletions examples/tracetest-azure-app-insights/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"]
45 changes: 42 additions & 3 deletions examples/tracetest-azure-app-insights/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,52 @@ services:
app:
build: .
environment:
CONNECTION_STRING: ${CONNECTION_STRING}
CONNECTION_STRING: ${APP_INSIGHTS_INSTRUMENTATION_STRING}
ports:
- "8080:8080"

# Cloud-based Managed Tracetest
tracetest-agent:
image: kubeshop/tracetest-agent:latest
environment:
# Find the Agent API Key here: https://docs.tracetest.io/configuration/agent
- TRACETEST_API_KEY=${TRACETEST_API_KEY}
# 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}
APP_INSIGHTS_ACCESS_TOKEN: ${APP_INSIGHTS_ACCESS_TOKEN}
APP_INSIGHTS_ARM_ID: ${APP_INSIGHTS_ARM_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
32 changes: 32 additions & 0 deletions examples/tracetest-azure-app-insights/resources/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID
ARM_ID=$APP_INSIGHTS_ARM_ID
ACCESS_TOKEN=$APP_INSIGHTS_ACCESS_TOKEN

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

echo "
type: DataStore
spec:
name: azureappinsights
type: azureappinsights
azureappinsights:
connectionType: direct
resourceArmId: ${ARM_ID}
accessToken: ${ACCESS_TOKEN}
useAzureActiveDirectoryAuth: false
" > /resources/datastore.yaml

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

apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: PollingProfile
spec:
id: azure
name: azure
strategy: periodic
periodic:
retryDelay: 4s
timeout: 10m
16 changes: 16 additions & 0 deletions examples/tracetest-azure-app-insights/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
19 changes: 19 additions & 0 deletions examples/tracetest-azure-app-insights/resources/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type: Test
spec:
id: W656Q0c4g
name: Test API
description: Test the App.
pollingProfile: azure
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 /"]
assertions:
- attr:http.response.status_code = 200
- attr:tracetest.span.duration < 500ms
18 changes: 0 additions & 18 deletions examples/tracetest-azure-app-insights/test-api.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions examples/tracetest-azure-app-insights/tests/test.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 35776f9

Please sign in to comment.