eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
723 stars 364 forks source link

Request response metrics - Experience using Azure Insights and Californium #2193

Open brbd1 opened 8 months ago

brbd1 commented 8 months ago

I am utilizing the Spring Boot framework to expose a CoAP server POST API. However, Azure App Insights is missing request metrics for these requests. When comparing with REST controller GET and POST requests, I've observed that they are being logged, but CoAP requests are not. I suspect that someone might have encountered a similar issue. I am seeking guidance regarding any special configurations or code changes that might be necessary to address this.

Command used to run app insights: java -javaagent:applicationinsights-agent-3.4.17.jar -jar .\demo-0.0.1-SNAPSHOT.jar

Update:

I've created a basic CoAP server without Spring Boot and performed tests using Azure insights. Despite this, the issue persists, indicating that it's unrelated to Spring Boot. My current assumption is that they're solely monitoring the HTTP protocol, not the UDP/COAP protocol.

boaks commented 8 months ago

However, Azure App Insights is missing request metrics for these requests.

I'm not common to "Azure app Insights" so I don't have any information, what the "request metrics" contains or which API that should use.

boaks commented 8 months ago

Despite this, the issue persists

I'm still not common to "Azure insights".

My current assumption is that they're solely monitoring the HTTP protocol, not the COAP protocol.

I guess so. If "Azure insights" offers a API to feed the data in, Californium has some API to provide some metrics. the glue between both API is then something you need to implement. But without any idea, how that "Azure insights" looks like, I'm not able to help you further.

brbd1 commented 8 months ago

Californium has some API to provide some metrics --> could you please share pointers on this, I will see how I can implement.

"Azure insights" is auto wired at JVM level. This is how it will get injected. java -javaagent:applicationinsights-agent-3.4.17.jar -jar .\demo-0.0.1-SNAPSHOT.jar

boaks commented 8 months ago

"Azure insights" is auto wired at JVM level.

Then I guess you need to ask Microsoft, how that "auto wired at JVM level" works. Or ask Microsoft to support "Californium".

boaks commented 8 months ago

For internal metric, Californium uses several callback interfaces in combination with a CounterStatisticManager implementation, e.g. NetStatLogger and NetSocketHealthLogger (both are only available for unix). Or DtlsHealthLogger for DTLS 1.2 and HealthStatisticLogger for CoAP.

These components are collecting the internal metrics. To read the values, a coap-resource similar to

Diagnose

maybe used. Or these metrics are forwarded to some other APIs. That's all not that easy, so before you start to spend time in it, I guess it wold help much more to see, how that data is intended to be passed to ""Azure insights" is auto wired at JVM level", otherwise you'r in danger of spending that time in vain.

boaks commented 8 months ago

I had a short view on the info at Application Insights. Unfortunately, I wasn't able to find some information, how that is intended to work with a "unprepared third party library" as Californium. I guess, you need to ask Microsoft. I will not be able to help you without the information, how to prepare java code in order to be used by the "auto wired at JVM level".

boaks commented 8 months ago

Let me recommend to adapt the title to be more specific, e.g.:

Experience using Azure Insights and Californium?

rogierc commented 6 months ago

No experience here. But reading the docs (https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-overview?tabs=aspnetcore) Azure seems to use OpenTelemetry.

OpenTelemetry has different options for collecting metrics. One is using a custom agent. An example here: https://github.com/open-telemetry/opentelemetry-java-examples/blob/main/javaagent/src/main/java/io/opentelemetry/example/javagent/Controller.java