microsoft / cpp_client_telemetry

1DS C++ SDK
Apache License 2.0
85 stars 48 forks source link

Add nativeSetIntTicketToken JNI implementation in android_build #1218

Open TedaLIEz opened 7 months ago

TedaLIEz commented 7 months ago

nativeSetIntTicketToken in LogManagerProvider.java is incomplete in the last PR: #1131

This PR aims:

  1. Implementation of nativeSetIntTicketToken in JNI, which turns out to be the setTicketToken in ILogManager.java
  2. Thread-safe in AuthTokensController.cpp to avoid race condition, we found some crashes because of race condition when using this sdk in Android system: Scudo ERROR: race on chunk header

Why adding locks in AuthTokensController.cpp?

We get the token after the app log in one account (MSA, AAD, etc), and our application is a multi-account application. So currently our solution is we cache the token once we get from the server, then every time client calls the logEvent method, it will set the ticket token internally. We don't have the dependencies on logger instanceswhen we in the process of getting token.

We can't guarantee all the logEvent method will be called only in main thread only, so this introduces the multi-threading issues.

TedaLIEz commented 7 months ago

@lalitb Would you like to review this PR? We want to leverage this API to support our telemetry, thanks!

lalitb commented 7 months ago

The CI failures are not related to this PR.