Zero-Code Instrumentation: Sending Micronaut App Signals to Azure Monitor
Logico_jp explains how developers can enable zero-code instrumentation with Micronaut applications to automatically send telemetry (traces and metrics) to Azure Monitor. This guide walks through concrete steps, from setup to testing, offering practical insights for Java and Micronaut practitioners working with Azure.
Zero-Code Instrumentation: Sending Micronaut App Signals to Azure Monitor
Author: Logico_jp | Posted August 13, 2025 |
This guide shows how to configure a Micronaut REST API backend to automatically send traces and metrics to Azure Monitor (Application Insights) using zero-code instrumentation—no manual tracing code needed. The approach covers both JVM and GraalVM native image deployments.
Background & Prerequisites
- This solution uses Micronaut (v4.9.0+), Java 21, Maven 3.9.10, Azure Monitor (Application Insights), and PostgreSQL Flexible Server.
- The application is a REST API for managing movie data, using PostgreSQL for persistence.
Related Reading
- Original Japanese post
- Send signals from Micronaut native image applications to Azure Monitor
- Micronaut Launch
-
[Zero-code OpenTelemetry](https://opentelemetry.io/docs/concepts/instrumentation/zero-code/)
Application Setup Overview
1. Project Archetype and Features
You can bootstrap your application using either the Micronaut CLI (mn
) or Micronaut Launch. Choose the following features:
graalvm
,management
,micrometer-azure-monitor
,azure-tracing
,yaml
,validation
,postgres
,jdbc-hikari
,data-jpa
2. Key Dependencies
To instrument HTTP and JDBC tracing with OpenTelemetry:
<dependency>
<groupId>io.micronaut.tracing</groupId>
<artifactId>micronaut-tracing-opentelemetry-http</artifactId>
</dependency>
<dependency>
<groupId>io.micronaut.tracing</groupId>
<artifactId>micronaut-tracing-opentelemetry-jdbc</artifactId>
</dependency>
For native image compatibility:
<dependency>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>graalvm-reachability-metadata</artifactId>
<version>0.11.0</version>
</dependency>
Add the GraalVM Maven plugin for native image configuration and optimization.
3. Environment Configuration
Configuration relies on application.yml
for:
- Database credentials (
JDBC_URL
,JDBC_USERNAME
,JDBC_PASSWORD
) - Azure Monitor Application Insights connection string (
AZURE_MONITOR_CONNECTION_STRING
)
Separate metric and trace configuration locations are needed—recommended via environment variables.
Sample snippet:
micronaut:
application:
name: micronaut-telemetry-movie
metrics:
enabled: true
export:
azuremonitor:
enabled: true
step: PT1M
connectionString: ${AZURE_MONITOR_CONNECTION_STRING}
datasources:
default:
driver-class-name: org.postgresql.Driver
db-type: postgres
url: ${JDBC_URL}
username: ${JDBC_USERNAME}
password: ${JDBC_PASSWORD}
azure:
tracing:
connection-string: ${AZURE_MONITOR_CONNECTION_STRING}
4. Native Image Configuration
Native image builds require generated metadata and plugin options:
- Run app with native-image agent to collect
config
andtrace
files. - Create configuration files (
reflect-config.json
,resource-config.json
, etc.) and place them insrc/main/resources/META-INF/native-image/{groupId}/{artifactId}
. - Set up
native-image.properties
to define initialization timing and CLI options (-Ob
for quicker builds).
Build the image with Maven:
mvn package -Dpackaging=native-image
Testing and Observability
- Run as Java, then Native Image: Confirm that traces and metrics are sent to Application Insights.
- Populate test data:
curl -X PUT https://<app-url>/api/movies
# Should respond: { "message":"Database initialized with default movies." }
- Verify data and metrics:
curl https://<app-url>/api/movies
curl https://<app-url>/metrics
JVM-specific metrics (e.g., jvm.memory.max
) may not be available or return placeholder values (e.g., -2) in native images.
- Logs to Traces Table Limitation:
- Zero-code cannot currently send application logs to Azure Monitor ‘traces’. Manual OpenTelemetry SDK configuration is required (custom
Appender
injection in controller constructor).
- Zero-code cannot currently send application logs to Azure Monitor ‘traces’. Manual OpenTelemetry SDK configuration is required (custom
Code Example
GitHub: anishi1222/micronaut-telemetry-movie
Further Reading and References
- Configure Native Image with the Tracing Agent
- Collect Metadata with the Tracing Agent
- Send metrics from Micronaut native image applications to Azure Monitor
- Send logs from Micronaut native image applications to Azure Monitor
Key Takeaways
- Zero-code instrumentation using Micronaut and OpenTelemetry simplifies exporting traces and metrics to Azure Monitor—no manual code required.
- Native images demand special configuration for accurate monitoring.
- Application logs require explicit OpenTelemetry SDK use for integration into Azure Monitor ‘traces’.
This post appeared first on “Microsoft Tech Community”. Read the entire article here