Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application
This project is an Azure distribution of the OpenTelemetry Spring Boot starter.
It allows you to get telemetry data on Azure with a Spring Boot native image application.
For a Spring Boot application running on a JVM runtime (not with a GraalVM native image), we recommend using the Application Insights Java agent.
Source code | Package (Maven) | API reference documentation | Product Documentation
For more information, please read introduction to Application Insights.
Import the OpenTelemetry Bills of Materials (BOM) by following the OpenTelemetry documentation.
Add the Spring Cloud Azure Starter Monitor dependency.
Instruction for Spring Boot native image applications.
All the features described in the OpenTelemetry Spring Boot starter documentation work with Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application.
You have just to replace the opentelemetry-spring-boot-starter
dependency by the spring-cloud-azure-starter-monitor
one.
In order to export telemetry data to Azure Monitor, you will need the connection string to your Application Insights resource. Go to Azure Portal, search for your resource. On the overview page of your resource, you will find the connection string in the top right corner.
You can then configure the connection string in two different ways:
- With the
APPLICATIONINSIGHTS_CONNECTION_STRING
environment variable - With the
applicationinsights.connection.string
system property. You can use-Dapplicationinsights.connection.string
or add the property to yourapplication.properties
file.
The Application Map uses the cloud role name to identify components on the map.
You can set the cloud role name with the spring.application.name
property. You have other options to set the cloud role role: see how to set the service name in the OpenTelemetry documentation.
At this step, you can build your Spring Boot native image application and start it:
mvn -Pnative spring-boot:build-image
docker run -e APPLICATIONINSIGHTS_CONNECTION_STRING="{CONNECTION_STRING}" {image-name}
where you have to replace {CONNECTION_STRING}
and {image-name}
by your connection string and the native image name.
You can disable the monitoring by setting the otel.sdk.disabled
property or the OTEL_SDK_DISABLED
environment variable to true.
- Enable Azure Monitor OpenTelemetry
- Configure Azure Monitor OpenTelemetry
- Add, modify, and filter OpenTelemetry
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.