Monitoring gRPC-Java Applications using Azure Monitor Application Insights

This entry is as of April 20, 2020.

Recently I wrote the following blog entry.

Codeless Java Application Monitoring using Azure Monitor Application Insights
https://logico-jp.io/2020/04/16/codeless-java-application-monitoring-using-azure-monitor-application-insights/

In the previous entry, Application Insights agent was used to monitor standalone Java applications and Java EE application server. In this entry, I describes how to monitor gRPC Java applications with Application Monitor Application Insights.

Java codeless application monitoring Azure Monitor Application Insights – public preview
https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-in-process-agent

gRPC Basics – Java
https://grpc.io/docs/tutorials/basic/java/
https://github.com/grpc/grpc-java/tree/master/examples/src/main/java/io/grpc/examples/routeguide

In this case, I use “route guide” sample application provided in gRPC-Java repository.

Before agent 3.0.0 Preview 3, dependency related exception occurred when starting applications. This exception was due to not JDK version but lack of OpenTelemetry related class files, because the agent jar file referred OpenTelemetry class files. In Java agent 3.0.0 preview 4, this issue was fixed and and I confirmed the agent worked fine (added on April 29, 2020).

Try it!

I used JDK 11 (11.0.7) but JDK 8 (1.8.252) to run sample applications. Application Insights configuration file (ApplicationInsights.json) was configured in the same manner as previous entry. In this case, I specified cloud role name to each application with environment variable (APPLICATIONINSIGHTS_ROLE_NAME) in order to clarify each application role since the same ApplicationInsights.json file was used.

# On terminal where server application runs...
export APPLICATIONINSIGHTS_ROLE_NAME=RouteGuideServer
# On terminal where client application runs...
export APPLICATIONINSIGHTS_ROLE_NAME=RouteGuideClient

We can also specify Connection String without ApplicationInsights.json.

export APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=00000000-0000-0000-0000-000000000000

When cloud role name is not specified, application insights resource name (grpc-test, in this case) is used as a cloud role name.

Now I’m ready. At first, I start server application.

java -javaagent:applicationinsights-agent-3.0.0-PREVIEW.2.jar -jar server.jar

Next, I start client application,

java -javaagent:applicationinsights-agent-3.0.0-PREVIEW.2.jar -jar client.jar

The following output should appear on client application terminal.

2020-04-20 11:57:55.860+09 INFO  applicationinsights.diagnostics - Application Insights Codeless Agent Attach Successful
Apr 20, 2020 11:57:57 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: *** GetFeature: lat=409,146,138 lon=-746,188,906
Apr 20, 2020 11:57:59 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Found feature called "Berkshire Valley Management Area Trail, Jefferson, NJ, USA" at 40.915, -74.619
Apr 20, 2020 11:57:59 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: *** GetFeature: lat=0 lon=0
Apr 20, 2020 11:57:59 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Found no feature at 0, 0
Apr 20, 2020 11:57:59 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: *** ListFeatures: lowLat=400,000,000 lowLon=-750,000,000 hiLat=420,000,000 hiLon=-730,000,000
Apr 20, 2020 11:57:59 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Result #1: name: "Patriots Path, Mendham, NJ 07945, USA"
location {
  latitude: 407838351
  longitude: -746143763
}
...
INFO: Sending message "Third message" at 1, 0
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Sending message "Fourth message" at 1, 1
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Got message "First message" at 0, 0
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Got message "Second message" at 0, 1
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Got message "Third message" at 1, 0
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Got message "Fourth message" at 1, 1
Apr 20, 2020 11:58:07 AM io.grpc.examples.routeguide.RouteGuideClient info
INFO: Finished RouteChat

“INFO: Finished RouteChat” indicates that client application was finished. After a few minutes, the following application map should be shown on Azure Portal.

Clicking “15 calls” and “investigate performance”, the performance view should be displayed.

Clicking “(15) Samples” button, samples are listed. Then click suggested sample to see end-to-end transaction detail, and dependencies and metrics should be displayed (see below).

Clicking “View all telemetry” button, all metrics captured in this call are shown.

User flow is also available.

Conclusion

I confirmed this agent and Application Insights could trace gRPC application, but as of now, additional libraries are required. This issue will be fixed in coming weeks.

If you have any issues and enhancement requests, please give your feedback to development team through GitHub Issues. Your feedback would be much appreciated.

Issue
https://github.com/microsoft/ApplicationInsights-Java/issues

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Google フォト

Google アカウントを使ってコメントしています。 ログアウト /  変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中