Today, we are happy to announce that Tracetest now works with Azure App Insights. This integration enables you and your team to fully leverage your system's observability from Azure Monitor. By using Tracetest in conjunction with Azure, you can improve your instrumentation setup, enhance quality using the new Tracetest Analyzer, test system behavior by creating assertions based on traces, and integrate it into your automated pipelines.
> *Check out [this hands-on example](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-azure-app-insights) of how Tracetest works with Azure App Insights, or check out [the recipe in the docs](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-with-azure-app-insights)!*
## What is Azure App Insights?
[Azure App Insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview?tabs=net) is an extension of [Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/overview) and provides application performance monitoring (APM) features. APM tools are useful to monitor applications from development, through test and into production in the following ways:
- _**Proactively**_ understand how an application is performing.
- _**Reactively**_ review application execution data to determine the cause of an incident.
## What is Tracetest?
[Tracetest](https://tracetest.io/) is an [open-source project, part of the CNCF landscape](https://github.com/kubeshop/tracetest). It allows you to quickly build integration and end-to-end tests, powered by your distributed traces.
Tracetest uses your existing distributed traces to power trace-based testing with assertions against your trace data at every point of the request transaction. You only need to point Tracetest to your existing trace data source or send traces to Tracetest directly!
Tracetest makes it possible to:
- Define tests and assertions against every single microservice that a trace goes through.
- Work with your existing distributed tracing solution, allowing you to build tests based on your already instrumented system.
- Define multiple transaction triggers, such as a GET against an API endpoint, a GRPC request, etc.
- Define assertions against both the response and trace data, ensuring both your response and the underlying processes worked correctly, quickly, and without errors.
- Save and run the tests manually or via CI build jobs with the Tracetest CLI.
## Tracetest Now Works with Azure App Insights!
[Tracetest now works with Azure App Insights](https://docs.tracetest.io/configuration/connecting-to-data-stores/azure-app-insights), enabling you to use Azure Monitor as a data store to pull traces generated by your distributed system.
In your existing observability setup, you can have the OpenTelemetry instrumentation configured in your code with OpenTelemetry Collector and send telemetry data to both Azure App Insights and Tracetest.
Or, you can decide to use the native approach by instrumenting your app directly with any of the available Azure Monitor distros to send data directly to the cloud provider and connect Tracetest to fetch data directly from Azure Monitor API.
**Why is it important?**
Enhancing your test suites with Azure App Insights and Trace-based Testing is crucial. When running integration tests, it can be difficult to pinpoint exactly where an HTTP transaction went wrong within a network of microservices. By enabling tracing, Tracetest can run tests with assertions against existing trace data for every service involved in the transaction. These tests can be used as part of your CI/CD process to ensure system functionality and catch regressions.
Combining the test creation capability of Tracetest with Azure App Insights allows you to take advantage of your existing instrumentation setup to explore new frontiers. You will now have the ability to evaluate complex system behaviors beyond just the initial request response, by analyzing the full list of steps taken to complete an asynchronous transaction.
## Try Tracetest with Azure App Insights
For this blog post, we are going to focus on the native connection from Tracetest to Azure App Insights which pulls telemetry data through the Azure Monitor API. Showcasing how you can instrument a simple Node.js containerized application, validate the traces from Tracetest and add a test to the generated telemetry data.
The first task is to gather the necessary information from your Azure Cloud. This information will be used to connect the Node.js app to your App Insights instance and for Tracetest to pull data from the Azure Monitor API.
The things you need are:
- [The App Insights Connection String](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-resources-app-insights-keys?view=azure-bot-service-4.0)
- [The App Insights ARM ID](https://microsoft.github.io/botframework-solutions/solution-accelerators/tutorials/view-analytics/2-get-application-insights-application-id/)
- [An Access Token](https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-azure-ad-api)
After gathering the required information, the next step is to download the quick start example from the Tracetest repo that can be found [here](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-azure-app-insights).
This repo contains the code to run the Node.js app, the docker-compose setup to run the services, and the configuration for the Tracetest server.
/src # the Node.js application code
/tests # Tracetest test YAML definitions
/tracetest # Tracetest server setup
.env # environment variables
docker-compose.yaml # main docker compose configuration
Dockerfile # Node.js app dockerization
Then, you can start overriding the template values for the configuration with the information you gathered in the first step.
In the `.env` file add the `CONNECTION_STRING` information
This will enable the Node.js instrumentation code to send traces to the Azure Cloud.
In the `tracetest/tracetest-provision.yaml` file add the `resourceArmId` and the `accessToken`
name: Custom Profile
This will enable Tracetest to connect with the Azure Monitor API and fetch traces from the Azure Cloud. With the configuration ready, you can now execute the example by running:
docker compose -f ./docker-compose.yaml -f ./tracetest/docker-compose.yaml up -d
[+] Running 3/3
⠿ Container tracetest-azure-app-insights-tracetest-1 Started 2.3s
⠿ Container tracetest-azure-app-insights-app-1 Started 0.5s
⠿ Container tracetest-azure-app-insights-postgres-1 Healthy
This will start the Tracetest server on port `11633`.
To validate that the configuration is correct and Tracetest is ready to start running tests, you can open the UI by opening `http://localhost:11663` in a browser.
Then, head to the settings page where you’ll find the Data Store configuration and you should see the Azure App Insights option selected with the configuration we added earlier.
At the bottom of the settings page, you will find the Test Connection button, click on it to validate that Tracetest is able to connect and fetch traces from Azure App Insights.
Now that we have everything set up, let’s execute a test!
To begin with, start by installing the Tracetest CLI:
brew install kubeshop/tracetest/tracetest
> *Note: Check out the [download page](https://tracetest.io/download) for more info.*
Then, from the example root folder, let’s use the test definition from the `tests` folder.
name: App Insights
description: App Insights
- key: Content-Type
- selector: span[tracetest.span.type="http"]
- attr:tracetest.selected_spans.count = 2
- attr:tracetest.span.duration < 1s
- selector: span[tracetest.span.type="http" name="GET /"]
- attr:http.target = "/"
By executing the following command:
tracetest test run -d tests/test.yaml -s http://localhost:11633
✔ App Insights (http://localhost:11633/test/<test-id>/run/1/test)
After executing the test, you can follow the result link back to the UI, which after a couple of minutes, should display the generated trace and test results.
This is just one of three recipes we have created covering different setups and ways you can combine the power of Azure App Insights and Tracetest.
To learn more, head to the following links:
- [Running Tracetest with Azure App Insights (ApplicationInsights Node.js SDK)](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-with-azure-app-insights)
- [Running Tracetest with Azure App Insights (Node.js + OpenTelemetry Collector)](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-with-azure-app-insights-collector)
- [Running Tracetest with Azure App Insights (OpenTelemetry Collector & Pokeshop API)](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-with-azure-app-insights-pokeshop/)
## What's next?
Would you like to learn more about Tracetest and what it brings to the table? Check the [docs](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-with-lightstep/) and try it out today by [downloading](https://tracetest.io/download) it today! Want to learn more about Azure App Insights? [Read more here](https://testkube.io/get-started).
Also, please feel free to join our [Discord community](https://discord.com/channels/884464549347074049/963470167327772703), give [Tracetest a star on GitHub](https://github.com/kubeshop/tracetest), or schedule a [time to chat 1:1](http://calendly.com/ken-kubeshop/otel-user-interview-w-tracetest).
Check out all of the latest and greatest happenings in the Tracetest world in our monthly newsletter!
📢 Exciting news! Tracetest has integrated with Dynatrace to offer unified observability for testing. Now you can create trace-based tests and monitor them over time.