From 1afc34ae6c29a5b07e2ba88ea92bb387579b3ebc Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Fri, 16 Aug 2024 09:53:16 -0600 Subject: [PATCH] updating collector example --- .../.env.template | 7 +-- .../collector.config.yaml | 4 +- .../docker-compose.yaml | 51 +++++++++++++++++-- .../test-api.yaml | 18 ------- .../tests/test.yaml | 21 -------- .../tracetest-tracing-backend.yaml | 9 ---- 6 files changed, 53 insertions(+), 57 deletions(-) delete mode 100644 examples/tracetest-azure-app-insights-collector/test-api.yaml delete mode 100644 examples/tracetest-azure-app-insights-collector/tests/test.yaml delete mode 100644 examples/tracetest-azure-app-insights-collector/tracetest-tracing-backend.yaml diff --git a/examples/tracetest-azure-app-insights-collector/.env.template b/examples/tracetest-azure-app-insights-collector/.env.template index ed9805a695..3377317e89 100644 --- a/examples/tracetest-azure-app-insights-collector/.env.template +++ b/examples/tracetest-azure-app-insights-collector/.env.template @@ -1,6 +1,7 @@ -# Azure -INSTRUMENTATION_KEY="" +# Get the required information here: https://app.tracetest.io/retrieve-token -# Tracetest API key and token TRACETEST_API_KEY="" TRACETEST_API_TOKEN="" + +# Azure +APP_INSIGHTS_INSTRUMENTATION_STRING="InstrumentationKey=14f0532a-aad4-4cb1-9bdb-64d021622efd;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/" diff --git a/examples/tracetest-azure-app-insights-collector/collector.config.yaml b/examples/tracetest-azure-app-insights-collector/collector.config.yaml index ca1919905a..0d2faf9e5a 100644 --- a/examples/tracetest-azure-app-insights-collector/collector.config.yaml +++ b/examples/tracetest-azure-app-insights-collector/collector.config.yaml @@ -9,7 +9,7 @@ processors: exporters: azuremonitor: - instrumentation_key: ${INSTRUMENTATION_KEY} + instrumentation_key: ${env:INSTRUMENTATION_KEY} otlp/tracetest-agent: endpoint: tracetest-agent:4317 tls: @@ -20,7 +20,7 @@ service: traces/tracetest: receivers: [otlp] processors: [batch] - exporters: [otlp/tracetest, otlp/tracetest-agent] + exporters: [otlp/tracetest-agent] traces/appinsights: receivers: [otlp] exporters: [azuremonitor] diff --git a/examples/tracetest-azure-app-insights-collector/docker-compose.yaml b/examples/tracetest-azure-app-insights-collector/docker-compose.yaml index f76c715c23..74bb4b67ea 100644 --- a/examples/tracetest-azure-app-insights-collector/docker-compose.yaml +++ b/examples/tracetest-azure-app-insights-collector/docker-compose.yaml @@ -4,20 +4,63 @@ services: build: . ports: - "8080:8080" + depends_on: + otel-collector: + condition: service_started + otel-collector: - image: otel/opentelemetry-collector-contrib:latest + image: otel/opentelemetry-collector-contrib:0.100.0 command: - "--config" - "/otel-local-config.yaml" volumes: - ./collector.config.yaml:/otel-local-config.yaml environment: - INSTRUMENTATION_KEY: ${INSTRUMENTATION_KEY} + INSTRUMENTATION_KEY: ${APP_INSIGHTS_INSTRUMENTATION_STRING} ports: - 4317:4317 + # 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} + 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 + diff --git a/examples/tracetest-azure-app-insights-collector/test-api.yaml b/examples/tracetest-azure-app-insights-collector/test-api.yaml deleted file mode 100644 index 207ffdb009..0000000000 --- a/examples/tracetest-azure-app-insights-collector/test-api.yaml +++ /dev/null @@ -1,18 +0,0 @@ -type: Test -spec: - id: W656Q0c4g - name: Test API - description: Test the App. - trigger: - type: http - httpRequest: - method: GET - url: http://app:8080 - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http" name="GET /"] - assertions: - - attr:http.status_code = 200 - - attr:tracetest.span.duration < 500ms diff --git a/examples/tracetest-azure-app-insights-collector/tests/test.yaml b/examples/tracetest-azure-app-insights-collector/tests/test.yaml deleted file mode 100644 index 9f66a40dbb..0000000000 --- a/examples/tracetest-azure-app-insights-collector/tests/test.yaml +++ /dev/null @@ -1,21 +0,0 @@ -type: Test -spec: - id: 4F1jCHJVR - name: App Insights - description: App Insights - trigger: - type: http - httpRequest: - url: http://app:8080/http-request - method: GET - headers: - - key: Content-Type - value: application/json - specs: - - selector: span[tracetest.span.type="http"] - assertions: - - attr:tracetest.selected_spans.count = 3 - - attr:tracetest.span.duration < 1s - - selector: span[tracetest.span.type="http" name="GET" http.target="/" http.method="GET"] - assertions: - - attr:http.url = "https://www.microsoft.com/" diff --git a/examples/tracetest-azure-app-insights-collector/tracetest-tracing-backend.yaml b/examples/tracetest-azure-app-insights-collector/tracetest-tracing-backend.yaml deleted file mode 100644 index e94dc41110..0000000000 --- a/examples/tracetest-azure-app-insights-collector/tracetest-tracing-backend.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -type: DataStore -spec: - id: current - name: azureappinsights - type: azureappinsights - azureappinsights: - connectionType: collector - useAzureActiveDirectoryAuth: false